ColumnView.GetFocusedDataRow() Method
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
Declaration
Returns
Type | Description |
---|---|
DataRow |
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:
- GridControl.MainView — returns the top-level view.
- GridControl.FocusedView — returns the focused view.
- GridControl.DefaultView — returns the currently maximized view.
- GridView.GetDetailView — returns a detail clone view of the specified master row.
- The
sender
parameter of Grid Control events.
Read the following topic for detailed information and examples: How to Access Detail Views in Code.