Skip to main content

GridView.MasterRowGetRelationName Event

Enables you to specify the pattern view that will represent a particular detail clone.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DXCategory("MasterDetail")]
public event MasterRowGetRelationNameEventHandler MasterRowGetRelationName

Event Data

The MasterRowGetRelationName 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.

Remarks

The MasterRowGetRelationName event is raised for individual detail clones. The current clone can be identified using the event’s e.RowHandle and e.RelationIndex parameters.

Use the e.RelationName parameter to specify the View that will represent the current detail. This parameter should be set to the name of the relationship which is associated with the required View in the GridControl.LevelTree tree. The grid control will locate the required View using the name of this relationship and will use this View to represent the current detail clone.

Handle the MasterRowGetRelationName event to do the following:

  • Specify a pattern View for individual detail clones. For example, the master View can have a single child relation. You can handle the MasterRowGetRelationName event to represent detail clones corresponding to different master rows using different Views.
  • Display detail data dynamically.
gridView1.MasterRowGetRelationName += (s, e) => {
    switch (e.RelationIndex) {
        case 0:
            e.RelationName = "Order Detail";
            break;
        case 1:
            e.RelationName = "Customer Details";
            break;
    }
};

Important

The level name must exactly match the name and case of the master-detail relation with which the view is associated. If a detail view displays data from a collection property, the level name must match the collection name.

Note

If you need to specify a View that does not belong to the GridControl.LevelTree tree, handle the GridView.MasterRowGetLevelDefaultView event instead.

Read the following topic for detailed information and examples: Working with Master-Detail Relationships in Code.

Run Demo: Master-Detail Mode with Events

See Also