Skip to main content

Obtaining 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.

#Obtaining Row Handles

Member Description
DataViewBase.FocusedRowHandle Specifies a 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 a mouse pointer.
DataViewBase.GetRowHandleByTreeElement Returns the handle of a row that contains a 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.

The following example shows how to find out which row has been clicked.


private void TableView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {
    int rowHandle = grid.View.GetRowHandleByMouseEventArgs(e as MouseEventArgs);
    MessageBox.Show(GetRowType(rowHandle), "Hit Info", MessageBoxButton.OK);
}
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";
}

#Obtaining 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 a specified handle, use the DataControlBase.GetRow or GridControl.GetRowByListIndex method. To obtain the focused row, use the GridControl.GetFocusedRow method. Row objects represent records in a data source.

#Special Row Handles

Row Description
New Item Row The Auto Filter Row allows an end-user to filter data on the fly. Typing text within this row automatically creates and applies a filter to the View. Its handle is returned by the DataControlBase.NewItemRowHandle property.
Automatic Filter Row This row allows an end-user to add new records to a data source. Its handle is returned by the DataControlBase.AutoFilterRowHandle property.
Invalid Row Generally, this row handle corresponds to a row that doesn't exist in a View. Its handle is returned by the DataControlBase.InvalidRowHandle property.