Setup a Master Detail Relationship

This exercise describes how to add DataGrids to define a Master-Detail relationship between two tables:

Master

  1. Click and drag a DataGrid from the Toolbox to the Design Sheet. This will be bound to the Master (Parent) dataset:
  2. To bind the DataGrid to the rows and columns of the Master dataset, select Set Data Binding from the control drop-down menu:
  3. Choose the Master dataset to bind to the DataGrid:

    The binding is shown on the DataGrid:

    (If the dataset binding string is truncated on smaller controls, to see the full string you can hover the mouse over the binding icon.)

Detail

  1. Click and drag a second DataGrid from the Toolbox to the Design Sheet. This will be mapped to the Detail (Child) dataset:
  2. To bind the DataGrid to the rows and columns of a Detail dataset, select Set Data Binding from the control drop-down menu:
  3. Choose the Detail dataset to bind to the DataGrid:

    The binding is shown on the DataGrid:

    Note:

  4. Add NavigationBars for the DataGrids. See: Navigate a Dataset
  5. Save your changes and click Run to run the form:

When you navigate the Master (Project) DataGrid, the Project is updated in the Detail (Collars) DataGrid.

Note that the Master-Detail relationship is based on the “Master dataset” setting of the Detail dataset. In this example, Project has already been configured as the Master dataset of the Collar dataset. Synchronisation between the bound DataGrids therefore works automatically.