Skip to main content

GridView.MasterRowGetRelationCount Event

Enables you to specify the number of details for individual master rows.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v23.2.dll

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

Declaration

[DXCategory("MasterDetail")]
public event MasterRowGetRelationCountEventHandler MasterRowGetRelationCount

Event Data

The MasterRowGetRelationCount event's data class is MasterRowGetRelationCountEventArgs. The following properties provide information specific to this event:

Property Description
RelationCount Gets or sets the number of relations for the master row.
RowHandle Gets a value identifying a master row.

Remarks

Handle the MasterRowGetRelationCount event when implementing dynamic detail data loading. The event fires for master rows so that you can specify the number of details the processed row will have. The master row is identified by the MasterRowGetRelationCountEventArgs.RowHandle parameter. The number of details can be specified via the MasterRowGetRelationCountEventArgs.RelationCount parameter.

gridView.MasterRowGetRelationCount += (s, e) => {
    e.RelationCount = 1;
};

Important

Initially the MasterRowGetRelationCount event fires with the e.RowHandle parameter set to GridControl.InvalidRowHandle. If you specify the number of relations for a master row based on a condition, set the e.RelationCount parameter to a positive value to enable master-detail mode when e.RowHandle is set to GridControl.InvalidRowHandle. Otherwise, master-detail mode will not be invoked.

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