See Also Example
Applies To
Grid.
Description
Determines whether the cell specified by the Col and Row Not available at design time; read-only at run time.
Usage
[form.]grid.CellSelected
Setting
The CellSelected property settings are:
Setting Description
True The specified cell is within the selected area.
False The specified cell is not within the selected area.
Remarks
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.
Data Type
Integer (Boolean)
Help:
Col, Row Properties
RowColChange Event
SelChange Event
SelEndCol, SelStartCol, SelEndRow, SelStartRow Properties
Programmer's Guide:
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
Randomize
' Choose a cell at random.
TRow = Int(Rnd * (Grid1.Rows - 1)) + 1
TCol = Int(Rnd * (Grid1.Cols - 1)) + 1
End Sub
Sub Grid1_Click ()
Grid1.Row = TRow
Grid1.Col = TCol
If Grid1.CellSelected Then
Label1.Caption = "You found it!"
Else
Label1.Caption = "Not yet. Try again."
End If
End Sub