See Also Example
Determines whether the cell specified by the Col and Row Not available at design time; read-only at run time. properties (the active cell) is within the grid's selected region.
The CellSelected property settings are:
True The specified cell is within the selected area.
False The specified cell is not within the selected area.
This property allows you to determine whether the user has selected a specific cell or a specific range of cells.
At run time, the user can select a range of cells by clicking a cell and then dragging the mouse or by pressing the Shift key and using the arrow keys.
Use the SelEndCol, SelStartCol, SelEndRow, SelStartRow Use the Col and Row properties to determine the active cell. properties to determine the selected region.
Col, Row Properties
SelEndCol, SelStartCol, SelEndRow, SelStartRow Properties
Chapter 3, "Creating and Using Controls"
The example selects a cell at random and tells you whether it is selected or not when the grid is clicked. To try this example, use the Add File command on the File menu to add GRID.VBX to the project, paste the code into the Declarations section of a new form, and then draw a grid and a label. For the label, set AutoSize to True. Press F5 to run the program.
Dim TRow As Integer
Dim TCol As Integer
Sub Form_Load ()
Grid1.Rows = 8 ' Set rows and columns.
Grid1.Cols = 5
' Choose a cell at random.
TRow = Int(Rnd * (Grid1.Rows - 1)) + 1
TCol = Int(Rnd * (Grid1.Cols - 1)) + 1
Sub Grid1_Click ()
Grid1.Row = TRow
Grid1.Col = TCol
If Grid1.CellSelected Then
Label1.Caption = "You found it!"
Label1.Caption = "Not yet. Try again."