Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you limit a flexgrid row selection to one row?? 1

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have a FlexGrid that I need to limit the user to selecting only one row at a time. How do I set this limit with code??? Every day above ground is a GOOD DAY!!!
 
SelectionMode Property?

Returns or sets a value that determines whether an MSHFlexGrid should allow regular cell selection, selection by rows, or selection by columns.

Syntax

object.SelectionMode [=value]

The SelectionMode property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
value An integer or constant that specifies the selection mode, as described in Settings.

Settings

The settings for value are:

Constant Value Description
flexSelectionFree 0 Free. This allows individual cells in the MSHFlexGrid to be selected, spreadsheet style. This is the default.
flexSelectionByRow 1 By Row. This forces selections to span entire rows, as in a multi-column list box or record-based display.
flexSelectionByColumn 2 By Column. This forces selections to span entire columns, as if selecting ranges for a chart or fields for sorting.
 

Set the RowSel property equal to the Row to make the selection the first row selected. Or, reverse the order and make Row = RowSel to force the selection to the last row selected. You can put the code in the mouseup event.


MSFlexGrid.Row = MSFlexGrid.RowSel

Mark
 
Thanks guys, I appreciate it. Every day above ground is a GOOD DAY!!!
 
I just wanted to comment since I have the same problem w/my prog. using the flexgrid. I don't like the way the flexgrid handles the multiple selections on a mousedown event. Even by putting the grid.rowsel = grid.row in the selChange() event, the flexgrid will still momentarily select multiple rows and upon a release of the mouse, the first row will only select. Is there a way to disable the mousedown event or eliminate the behavior or still seeing, even momentarily, the multiple rows selected?

Thanks,
CJ
 
Although the multiple row selection will flash momentarily when the user tries the normal Windows multiple selection (click on a row, hold the shift key down and click on another row) these routines will give you what you need:

Code:
Private Sub fg_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    fg.Redraw = False
End Sub

Private Sub fg_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    fg.RowSel = fg.Row
    fg.Redraw = True
End Sub


Mark

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top