Microsoft KB Archive/113589

= How to Highlight an Entire Row of Cells in the Grid Control =

Article ID: 113589

Article Last Modified on 10/28/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q113589



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.



Steps 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: KB113589

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.