GridView.GetDetailView(Int32, Int32) Method

Gets the detail View for the master row.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

public BaseView GetDetailView(
    int rowHandle,
    int relationIndex
)
Public Function GetDetailView(
    rowHandle As Integer,
    relationIndex As Integer
) As BaseView

Parameters

Name Type Description
rowHandle Int32

The master row handle.

relationIndex Int32

The relationship index in the data source.

Returns

Type Description
BaseView

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

Remarks

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.

NOTE

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 real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.

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 dView = gridView1.GetDetailView(e.RowHandle, (sender as GridView).GetVisibleDetailRelationIndex(e.RowHandle)) as GridView;
    dView.CustomRowCellEdit += DView_CustomRowCellEdit;
    RepositoryItemComboBox cBox = new RepositoryItemComboBox();
    cBox.Items.AddRange(new string[] { "A", "B", "C", "D" });
    gridControl1.RepositoryItems.Add(cBox);
    dView.Columns["Col2"].ColumnEdit = cBox;
}
See Also