Back to Devexpress

ColumnView.GetFocusedDataRow() Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-0134d881.md

latest5.6 KB
Original Source

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.v25.2.dll

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

Declaration

csharp
public DataRow GetFocusedDataRow()
vb
Public Function GetFocusedDataRow As DataRow

Returns

TypeDescription
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:

csharp
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();
    //...
}
vb
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):

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

FocusedRowHandle

DataSource

GetDataSourceRowIndex(Int32)

GetDataRow(Int32)

GetRow(Int32)

GetRowCellValue

SetRowCellValue

Edit Data. Create Cell Editors. Validate User Input

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace