Obtain Row Handles
- 2 minutes to read
There are multiple methods that allow you to obtain row handles, visible indices and indices in a data source. This topic lists and describes these methods.
Obtain Row Handles
Member | Description |
---|---|
DataViewBase.FocusedRowHandle | Specifies the focused row’s handle if the DataViewBase.NavigationStyle property isn’t set to GridViewNavigationStyle.None. |
DataViewBase.GetRowHandleByMouseEventArgs | Returns the handle of a row located under the mouse pointer. |
DataViewBase.GetRowHandleByTreeElement | Returns the handle of a row that contains the specified element. |
GridControl.GetRowHandleByVisibleIndex | Returns a row’s handle by specifying its visible index. |
GridControl.GetRowHandleByListIndex | Returns a row’s handle by specifying its index in a data source. |
GridControl.GetListIndexByRowHandle | Returns the specified data row’s index in a data source. |
The following example shows how to obtain which row has been clicked.
private void TableView_MouseDown(object sender, MouseButtonEventArgs e) {
int rowHandle = grid.View.GetRowHandleByMouseEventArgs(e as MouseEventArgs);
MessageBox.Show(GetRowType(rowHandle), "Hit Info");
}
private string GetRowType(int rowHandle) {
if (grid.IsGroupRowHandle(rowHandle))
return "Group Row";
if (rowHandle == GridControl.AutoFilterRowHandle)
return "Automatic Filter Row";
if (rowHandle == GridControl.NewItemRowHandle)
return "New Item Row";
if (rowHandle == GridControl.InvalidRowHandle)
return "Invalid Row";
return "Data Row";
}
Obtain Data Rows and Row Indices in a Datasource
Row handles and visible indices reflect the visual order of rows in a View, and these may change as rows change their positions or visibility. To refer to a particular row in a data source, you should use a list index (a row’s index in a data source). To obtain a row’s list index by specifying its handle, use the GridControl.GetRowListIndex method.
To obtain a row object that corresponds to a row with the specified handle, use the DataControlBase.GetRow, GridControl.GetRowAsync or GridControl.GetRowByListIndex method. To obtain the focused row, use the GridControl.GetFocusedRow method. Row objects represent records in a data source. For instance, a DataRow object represents a record in a DataTable.