windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-7e8a0f0b.md
Enables you to specify the number of details for individual master rows.
Namespace : DevExpress.XtraGrid.Views.Grid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("MasterDetail")]
public event MasterRowGetRelationCountEventHandler MasterRowGetRelationCount
<DXCategory("MasterDetail")>
Public Event MasterRowGetRelationCount As MasterRowGetRelationCountEventHandler
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. |
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;
};
AddHandler gridView.MasterRowGetRelationCount, Sub(s, e)
e.RelationCount = 1
End Sub
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