When using GridControl, you may need to perform operations on rows using code. For instance, to focus (select) a specific row in code, you first need to get the corresponding row identifier and assign it to the GridControl.SelectedRowHandle property. Alternatively, you may wish to identify the type of the row or row value that is currently hovered. In these cases, you will need to know how to identify rows within the grid.
Rows in a GridControl are identified by unique integer values - row handles. A grid associates its rows with these values using the following rules:
|GridControl.FindRowByValue||Searches for the value in the column and returns the handle of the corresponding row.|
|GridControl.GetRowHandle||Returns the handle of the row which corresponds to the specified record in the data source.|
|GridControl.SelectedRowHandle||Gets or sets the selected row handle. This is a bindable property.|
Row handles are used by GridControl to reference its rows. For instance, the GridControl.SelectedRowHandle property specifies the selected row by its handle. The GridControl.SelectionChanged event passes the currently selected row handle as a parameter. When accessing (GridControl.GetCellValue) or changing (GridControl.SetCellValue) cell values, you need to provide the appropriate row handle.
To obtain information on an individual group of rows, use the GridControl.GetGroupInfo and GridControl.GetGroupRowValue method with the appropriate group row handle passed as a parameter. To collapse or expand a group of rows, call the GridControl.CollapseGroupRow or GridControl.ExpandGroupRow method with the specified group row handle. When collapsing or expanding a group row, the GridControl.GroupRowCollapsing, GridControl.GroupRowCollapsed, GridControl.GroupRowExpanding and GridControl.GroupRowExpanded events also identify the affected group row by its handle.
Row handles reflect the visual order of rows in a grid, and these may change as rows change their positions. In many cases, the best solution for referring to specific rows is to use objects that represent records in the bound data source. To refer to a particular row in a data source, you can use a row's index in a data source. To obtain a row's list index by specifying its handle, use the GridControl.GetSourceRowIndex method. To obtain a row object that corresponds to a row with the specified handle, use GridControl.GetRow.