How to Highlight an Entire Row of Cells in the Grid Control
ID: Q113589
|
The information in this article applies to:
-
Microsoft Visual Basic programming system for Windows, versions 2.0, 3.0
SUMMARY
The sample code in this article demonstrates how to highlight an entire
row of cells for the Grid control including the cell that you select.
This sample uses the following properties: SelStartRow, SelStartCol,
SelEndRow, and SelEndCol. In addition to highlighting the entire row,
the sample code also highlights the cell you clicked.
MORE INFORMATIONSteps to Highlight an Entire Row of Cells in a Grid
- Start a new project in Visual Basic. Form1 is created by default.
- Add one Grid control (Grid1) to Form1.
- Set both the Cols and Rows properties of the Grid1 control to 8.
- Place the following code in the Grid1 Click event procedure of Form1:
Sub Grid1_Click ()
' Following statements highlight all cells except clicked cell:
If grid1.Row > 0 Then
grid1.SelStartRow = grid1.Row
grid1.SelEndRow = grid1.Row
grid1.SelStartCol = grid1.fixedcols ' Start after fixed columns.
grid1.SelEndCol = grid1.cols - 1 ' end at the last columns.
' Rows & columns are numbered starting at 0,
' so the last column is 1 less than the Cols property
End If
' Following two lines help highlight the individual cell, so change
' these lines to comments to see the difference:
grid1.Row = 0
grid1.Col = 0
End Sub
- From the Run menu, choose Start (ALT, R, S), or press the F5 key to run
the program. Click a cell in Grid1.
Additional query words:
1.00 2.00 3.00
Keywords :
Version :
Platform :
Issue type :
|