Home › Forums › WinForms controls › Xceed Grid for WinForms › How to get the parent row’s data object in a DetailGrid? › Reply To: How to get the parent row’s data object in a DetailGrid?
Here’s a summarised version of the solution that Tech Support gave me:
When defining the detail grid, set the following properties. This assumes that it is the ‘Invoices’ property on each Customer object that holds the collection of Invoices.
MyDetailGrid.DataSource = null;
MyDetailGrid.DataMember = “Invoices”;
If you want to load the detail on demand (ie. only when you expand the customer row):
1. subscribe to the DetailGrid’s CollapsedChanged event
2. set SynchronizeDetailGrids = false on the DetailGrid
3. bind to the collection in the CollapsedChanged event as follows:
private void DetailGridTemplate_CollapsedChanged( object sender, EventArgs e )
if( !( ( DetailGrid ) sender ).Collapsed )
( ( DetailGrid ) sender ).SetDataBinding( null, “Invoices” );
Imported from legacy forums. Posted by Jamie (had 3219 views)