This seems fine. The only thing that could be done differently is to load all the data into you DataSet when first loading your form, and then simply bind the detail girds as it gets expended.
private void Form1_Load( object sender, EventArgs e )
detailGridTemplate1.Collapsed = true;
detailGridTemplate1.CollapsedChanged += new EventHandler( detailGridTemplate1_CollapsedChanged );
gridControl1.SynchronizeDetailGrids = false;
gridControl1.SetDataBinding( this.northwindDataSet.Suppliers, “” );
//Assuming a Suppliers (master) / Products (detail) relationship called “SuppliersProducts” in the DataSet.
this.suppliersTableAdapter.Fill( this.northwindDataSet.Suppliers );
this.productsTableAdapter.Fill( this.northwindDataSet.Products );
void detailGridTemplate1_CollapsedChanged( object sender, EventArgs e )
DetailGrid grid = sender as DetailGrid;
if( !grid.Collapsed )
//This will permit to fill the DetailGrid with the data related to the parent row, by using the relationship
grid.SetDataBinding( grid.ParentDataRow.Cells[ “SuppliersProducts” ].Value, string.Empty );
grid.SetDataBinding( null, string.Empty );
This is what I was trying to do, without succes. When setting the synchronizeDetailGrids to false, it was always showing me the first result (bad relationship).
I have tried another time this morning and now all works fine. Thanks you for your help and your patience.
Imported from legacy forums. Posted by Daniel (had 5492 views)