Skip to main content

GridView.MasterRowGetRelationDisplayCaption Event

Allows you to specify a detail view’s caption.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid


public event MasterRowGetRelationNameEventHandler MasterRowGetRelationDisplayCaption

Event Data

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.

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.

Custom Captions for Individual Detail Views

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):

  • RowHandle — specifies the processed master row’s handle.
  • RelationIndex — specifies the detail view’s index.

After you identified the processed detail view, use the RelationName event argument to specify the tab caption.


To specify a custom detail view (not only a caption) for a specific master row, use the MasterRowGetRelationName or MasterRowGetLevelDefaultView event.

Custom Images and Appearance Settings for Individual Detail Tabs

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:

  • Appearance — provides access to background and foreground colors, font style, and so forth.
  • ImageOptions — provides access to a raster or vector image assigned to the tab.

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.

HTML-Formatted Tab Captions

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.

Custom Detail Tab Captions

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";
See Also