Skip to main content

ColumnView.GetFocusedDataRow() Method

Returns a DataRow in the bound DataTable that contains data for the focused grid row.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public DataRow GetFocusedDataRow()

Returns

Type Description
DataRow

A DataRow that specifies a row of data in a DataTable.

Remarks

The following example handles the GridView’s FocusedRowChanged event to obtain a DataRow object in the grid’s data source that corresponds to the focused row:

using System.Data;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;

void GridView1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) {
    GridView view = sender as GridView;
    DataRow dataRow = view.GetFocusedDataRow();
    //...
}

Use the following methods to get an object that contains data for a specific row (by the row’s handle):

  • GetRow(Int32) — Returns an Object in the bound data source that contains data for the specified grid row.

    To get the focused grid row’s data row, use the GetFocusedRow() method.

  • GetDataRow(Int32) — Returns a DataRow in the bound DataTable that contains data for the specified grid row.

    To get the focused grid row’s DataRow, use the GetFocusedDataRow() method.

    Note

    If the bound data source is a custom collection, these methods return null (Nothing in VB).

For a group row, these methods return the first grid row’s underlying data row.

Master-Detail Grid

Views that you assign to detail levels are Pattern Views. The Data Grid dynamically creates a Clone View based on the settings of its pattern view when a user expands a master row (a clone view is a copy of a pattern view).

Pattern views do not contain any real data. Do not use the GetFocusedDataRow method of pattern views. Use the GetFocusedDataRow method of clone views to access detail data at runtime.

Use the following methods to obtain views:

Read the following topic for detailed information and examples: How to Access Detail Views in Code.

See Also