Issue: Cannot highlight/select the DataGrid Row and/or Cell through Code
Level: Beginner
Knowledge Required:
To understand the following solution you must have the knowledge of:
- DataGrid View Control
Description:
To select the Particular row and/or cell of DataGrid View Control there are several techniques. Firstly you need to decide whether user can select more than one rows or cells. For this purpose you can use MultiSelect Property of DataGrid Control:
MultiSelect is a Boolean Property that can have values:
True = Enable user to select multiple rows and/or cells
False = Disable user to select only one row and/or cell at a time
To select particular Cell:
Tech #1:
myDataGrid.CurrentCell = myDataGrid(col, row)
where
col = Column Index
row = Row Index
Tech #2:
myDataGrid.Rows(row).Cells(col).Selected = True
To select particular Row:
myDataGrid.Rows(row).Selected = True
To clear previously selected Cells:
myDataGrid.ClearSelection
No comments:
Post a Comment