GridView.GetDetailView(Int32, Int32) Method
Gets the detail/clone view associated with the specified master row and relation index, if the detail view is currently visible.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v26.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
Parameters
| Name | Type | Description |
|---|---|---|
| rowHandle | Int32 | The master row handle. |
| relationIndex | Int32 | The index of the detail relationship in a data source when the master row has multiple detail views. |
Returns
| Type | Description |
|---|---|
| BaseView | The detail/clone view 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.
To ensure the detail view is visible before accessing it, use one of the following methods:
To check whether a master row is expanded, use the GridView.GetMasterRowExpanded method.
The relationIndex identifies the detail relationship in the underlying data source. The order of detail views may differ from the order of relationships in the data source.
To obtain the currently visible detail view, use the the GridView.GetVisibleDetailView method.
See the following help topics for detailed information:
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 such Views.
- 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 following code snippet accesses a detail view when a master row is expanded and assigns a combo box editor to the “Col2” column:
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Views.Grid;
void gridView1_MasterRowExpanded(object sender, CustomMasterRowEventArgs e){
GridView masterView = sender as GridView;
// Get the index of the visible detail relationship for the expanded master row.
int visibleDetailRelationIndex = masterView.GetVisibleDetailRelationIndex(e.RowHandle);
// Retrieve the visible detail (clone) view.
GridView detailView = masterView.GetDetailView(e.RowHandle, visibleDetailRelationIndex) as GridView;
if (detailView != null) {
// Create a combo box editor and populate it with items.
RepositoryItemComboBox cBox = new RepositoryItemComboBox();
cBox.Items.AddRange(new string[] { "A", "B", "C", "D" });
// Add the combo box editor to the grid's repository.
masterView.Grid.RepositoryItems.Add(cBox);
// Assign the combo box editor to the "Col2" column in the detail view.
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.