SelectionMode Property

Returns or sets whether the control will select cells in a free range, by row, by column, or like a listbox.

Syntax

[form!]VSFlexGrid.SelectionMode[ = SelModeSettings ]

Remarks

The settings for the SelectionMode property are described below:

 

Constant

Value

Description

flexSelectionFree

0

Allows selections to be made as usual, spreadsheet-style.

flexSelectionByRow

1

Forces selections to span entire rows. Useful for implementing record-based displays.

flexSelectionByColumn

2

Forces selections to span entire columns. Useful for selecting ranges for a chart or fields for sorting.

flexSelectionListBox

3

Similar to flexSelectionByRow, but allows non-continuous selections. Pressing CTRL and clicking with the mouse toggles the selection for an individual row. Dragging the mouse over a group of rows toggles their selected state.

 

When SelectionMode is set to flexSelectionListBox, you may use the IsSelected property allows you to read and set the selected status of individual rows, and the SelectedRows property to enumerate selected rows.

  Private Sub fg_Click()

   

     If fg.MouseRow < fg.FixedRows And fg.MouseCol > -fg.FixedCols Then

       fg.SelectionMode = flexSelectionByColumn

     End If

       

     If fg.MouseCol < fg.FixedRows And fg.MouseRow >= fg.FixedRows Then

       fg.SelectionMode = flexSelectionByRow

     End If

       

  End Sub

To prevent range selection altogether, set the AllowSelection property to False.

Data Type

SelModeSettings (Enumeration)

Default Value

flexSelectionFree (0)

See Also

VSFlexGrid Control