GridView.GetDetailView(Int32, Int32) Method
Gets the detail View for the master row.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v23.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
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
The GetDetailView
method returns a detail View if the detail View is visible. You need to display the ditail 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, you can 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 GetDetailView
method for these Views.
The GetDetailView
method can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which the user interacts at runtime.
- GridControl.MainView - returns the top most View in a grid;
- GridControl.FocusedView - returns the focused View;
- GridControl.DefaultView - returns the currently maximized View;
- the sender parameter of View specific events;
GridView.GetDetailView
- returns a detail clone View for a specific master row.
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" });
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.