This sample demonstrates the grid that is used in the Windows Forms Currency Manager Master Details setup with data source and data member properties inside a form.
Features:
When you navigate through the records in the parent table, the data source of the child control will be replaced.
This sample also shows the Engine.BindToCurrencyManager property, which lets you disable the binding of the grid to a currency manager.
This is how the sample looks.
The following code shows how to establish relations between the tables.
DataColumn parentColumn = parentTable.Columns["parentID"]; DataColumn childColumn = childTable.Columns["ParentID"]; dSet.Relations.Add("ParentToChild", parentColumn, childColumn);
The following code demonstrates how to assign the data source without auto-populating relations.
// Set the master-detail grids. this.parentTableGrid.DataSource = parentTable; //master this.parentTableGrid.TableDescriptor.Relations.Clear(); // don't autopopulate relations. this.parentToChildGrid.DataSource = parentTable; //detail1 this.parentToChildGrid.DataMember = "ParentToChild"; //detail1 this.parentToChildGrid.TableDescriptor.Relations.Clear(); // don't autopopulate relations. this.childToGrandChildGrid.DataSource = parentTable; //detail2 this.childToGrandChildGrid.DataMember = "ParentToChild.ChildToGrandChild"; //detail2 this.childToGrandChildGrid.TableDescriptor.Relations.Clear(); // don't autopopulate relations. // Code to disable the BindToCurrencyManager for the HierarchyGrid. this.hierarchyGrid.DataSource = parentTable; this.hierarchyGrid.Engine.BindToCurrencyManager = false; // Don't attach this one to the CurrencyManager.