windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-1b9528d8.md
Allows you to specify a detail view’s caption.
Namespace : DevExpress.XtraGrid.Views.Grid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("MasterDetail")]
public event MasterRowGetRelationNameEventHandler MasterRowGetRelationDisplayCaption
<DXCategory("MasterDetail")>
Public Event MasterRowGetRelationDisplayCaption As MasterRowGetRelationNameEventHandler
The MasterRowGetRelationDisplayCaption event's data class is MasterRowGetRelationNameEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| RelationIndex | Gets the relation index that identifies the affected detail. Inherited from CustomMasterRowEventArgs. |
| RelationName |
For the GridView.MasterRowGetRelationName event this property gets or sets the name of the level whose bound View will be used to represent the currently processed detail’s data.
For the GridView.MasterRowGetRelationDisplayCaption event this property gets or sets the display caption for the currently processed relation.
| | RowHandle | Gets the handle of the currently processed master row in the current View. Inherited from CustomMasterRowEventArgs. |
A detail view’s ViewCaption property allows you to specify a caption that is displayed in a detail tab. Ensure that the ShowDetailTabs option is enabled; otherwise, tabs are not displayed. If the EnableDetailToolTip option is enabled, this caption is also displayed in detail tooltips.
If the caption is not specified, the detail view uses the LevelName property value.
The MasterRowGetRelationDisplayCaption event fires for each detail view and allows you to specify a custom tab caption.
Use the following event arguments to identify the processed master row and detail view (if the master row displays multiple detail views):
After you identified the processed detail view, use the RelationName event argument to specify the tab caption.
Tip
To specify a custom detail view (not only a caption) for a specific master row, use the MasterRowGetRelationName or MasterRowGetLevelDefaultView event.
The DetailTabStyle event fires for each detail view. This event allows you to assign a custom image to the processed tab and apply custom appearance settings to the tab caption.
Use the Caption event argument to obtain or change the processed tab caption. The following arguments allow you to specify the tab style:
You can also use the IsSelected argument to apply a specific style depending on whether the tab is selected.
The RefreshDetailTab(Int32) method allows you to update a detail tab at runtime.
You can enable the master view’s AllowHtmlDrawDetailTabs option to parse HTML-inspired tags in detail tab captions.
The code below handles the MasterRowGetRelationDisplayCaption event to specify custom tab captions.
In the image below, tab captions contain the master row’s Company Name column values.
using DevExpress.XtraGrid.Views.BandedGrid;
private void advBandedGridView1_MasterRowGetRelationDisplayCaption(object sender, MasterRowGetRelationNameEventArgs e) {
AdvBandedGridView view = sender as AdvBandedGridView;
string companyName = (string)view.GetRowCellValue(e.RowHandle, colCompanyName);
if(e.RelationIndex == 1)
e.RelationName = $"{companyName}: Products";
}
Imports DevExpress.XtraGrid.Views.BandedGrid
AddHandler advBandedGridView1.MasterRowGetRelationDisplayCaption, AddressOf advBandedGridView1_MasterRowGetRelationDisplayCaption
Private Sub advBandedGridView1_MasterRowGetRelationDisplayCaption(sender As Object, e As MasterRowGetRelationNameEventArgs)
Dim view As AdvBandedGridView = TryCast(sender, AdvBandedGridView)
Dim companyName = CStr(view.GetRowCellValue(e.RowHandle, colCompanyName))
If e.RelationIndex = 1 Then e.RelationName = $"{companyName}: Products"
End Sub
See Also