GridView.GetDetailView(Int32, Int32) Method
Gets the detail View for the master row.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
row |
Int32 | The master row handle. |
relation |
Int32 | The relationship index in the data source. |
#Returns
Type | Description |
---|---|
Base |
A Base |
#Remarks
The GetDetailView
method returns a detail View if the detail View is visible. Display the detail view if it is hidden.
Use the GridView.GetMasterRowExpanded method to obtain a master row’s expanded state. Use the GridView.SetMasterRowExpanded or GridView.SetMasterRowExpandedEx method to expand the master row.
The relationIndex
parameter specifies the detail View’s relationship index if the master row has several details.
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, use the GridView.GetVisibleDetailView method instead of the GetDetailView
method.
Read the following help topics for detailed information: Master-Detail Relationships, Working with Master-Detail Relationships in Code.
Note
Detail pattern Views do not contain data and they are never displayed within the Grid Control. Do not use the Get
method for these Views.
The Get
method can only be used with Views that display real data within the Grid Control. Use the following methods to access such Views.
- Grid
Control. - returns the top most View in a grid;Main View - Grid
Control. - returns the focused View;Focused View - Grid
Control. - returns the currently maximized View;Default View - the sender parameter of View-specific events;
Grid
- returns a detail clone View for a specific master row.View. Get Detail View
The following code snippet adds 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" });
masterView.Grid.RepositoryItems.Add(cBox);
detailView.Columns["Col2"].ColumnEdit = cBox;
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetDetailView(Int32, Int32) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.