windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-0134d881.md
Returns a DataRow in the bound DataTable that contains data for the focused grid row.
Namespace : DevExpress.XtraGrid.Views.Base
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
public DataRow GetFocusedDataRow()
Public Function GetFocusedDataRow As DataRow
| Type | Description |
|---|---|
| DataRow |
A DataRow that specifies a row of data in a DataTable.
|
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();
//...
}
Imports System.Data
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
Private Sub GridView1_FocusedRowChanged(ByVal sender As Object, ByVal e As FocusedRowChangedEventArgs)
Dim view As GridView = TryCast(sender, GridView)
Dim dataRow As DataRow = view.GetFocusedDataRow()
'...
End Sub
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.
GetDataRow(Int32) — Returns a DataRow in the bound DataTable that contains data for the specified grid row.
For a group row, these methods return the first grid row’s underlying data row.
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:
sender parameter of Grid Control events.Read the following topic for detailed information and examples: How to Access Detail Views in Code.
See Also