Skip to main content

Obtain Row Handles

  • 3 minutes to read

The GridControl includes 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(MouseEventArgs) Returns the handle of a row located under the mouse pointer.
DataViewBase.GetRowHandleByTreeElement(DependencyObject) Returns the handle of a row that contains the specified element.
GridControl.GetRowHandleByVisibleIndex(Int32) Returns a row’s handle by its visible index..
GridControl.GetRowHandleByListIndex(Int32) Returns a row’s handle by its index in a data source.
GridControl.GetListIndexByRowHandle(Int32) Returns a row’s index in a data source by its row handle.
DataControlBase.FindRow(Object) Searches for the data row in the GridControl or TreeListControl and returns the row’s handle.
DataControlBase.FindRowByValue(ColumnBase, Object) Searches for the value in the column and returns the handle of the corresponding row.
DataControlBase.FindRowByValue(String, Object) Searches for the value in the column and returns the handle of the corresponding row.
GridControl.FindRowByValueAsync(ColumnBase, Object) Searches for the value in the column and returns the handle of the corresponding row asynchronously.
GridControl.FindRowByValueAsync(String, Object) Searches for the value in the column and returns the handle of the corresponding row asynchronously.
DataViewBase.GetNextRowHandle(Int32) Returns the handle of the row that follows the specified row.
DataViewBase.GetPrevRowHandle(Int32) Returns the handle of the row that precedes the specified row.

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

See Also