Skip to main content

GridView.GetDetailView(Int32, Int32) Method

Gets the detail View for the master row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v22.1.dll

NuGet Package: DevExpress.Win.Grid


public BaseView GetDetailView(
    int rowHandle,
    int relationIndex


Name Type Description
rowHandle Int32

The master row handle.

relationIndex Int32

The relationship index in the data source.


Type Description

A BaseView descendant that is the detail clone. null (Nothing in Visual Basic) if the specified detail clone does not exist.


You can obtain a detail View using the GetDetailView method only if this View is visible. The GridView.GetMasterRowExpanded method can be used to determine a master row’s expanded state. If a master row has several details, use the GridView.GetVisibleDetailRelationIndex method to identify the visible View’s relationship index. To obtain a detail View that is currently hidden, you first need to make this View visible via the GridView.SetMasterRowExpanded or GridView.SetMasterRowExpandedEx method.

The order of detail Views may not match the order of detail relationships in the data source. Take this into consideration when specifying the relationIndex parameter, which identifies the index of the relationship in the underlying data source.

To get the currently visible detail View, you can use the GridView.GetVisibleDetailView method instead of the GetDetailView method.

Refer to the Master-Detail Relationships and Working with Master-Detail Relationships in Code topics for additional information.


Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the GetDetailView member must not be invoked for these Views. The GetDetailView member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The code sample below illustrates how to add a custom editor to a detail view.

using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Views.Grid;


private void gridView1_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e){
    GridView masterView = sender as GridView;
    int visibleDetailRelationIndex = masterView.GetVisibleDetailRelationIndex(e.RowHandle);
    GridView detailView = masterView.GetDetailView(e.RowHandle, visibleDetailRelationIndex) as GridView;
    RepositoryItemComboBox cBox = new RepositoryItemComboBox();
    cBox.Items.AddRange(new string[] { "A", "B", "C", "D" });
    detailView.Columns["Col2"].ColumnEdit = cBox;
See Also