Dela via


How to: Create a Master/Detail Form by Using Two DataRepeater Controls (Visual Studio)

You can display related data by using two or more DataRepeater controls to create a master/detail form. For example, you might want to display a list of customers in one DataRepeater, and when the user selects a customer, display a list of that customer's orders in a second DataRepeater.

You can display related data by dragging detail items that share the same master table node from the Data Sources window onto a DataRepeater control. For example, if you have a data source that has a Customers table and a related Orders table, you see both tables as top-level nodes in the tree view in the Data Sources window. Expand the Customers node so that you can see the columns. Notice that the last column in the list is an expandable node that represents the Orders table. This node represents the related orders for a customer.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

  1. Drag two DataRepeater controls from the Visual Basic PowerPacks tab in the Toolbox to a form or container control.

  2. Drag the sizing and position handles to size the controls and position them side-by-side.

  3. On the Data menu, click Show Data Sources.

    Note

    If the Data Sources window is empty, add a data source to it. For more information, see Data Sources Overview.

  4. In the Data Sources window, select the top-level node for the master table.

  5. Change the drop type of the master table to Details by clicking Details in the drop-down list on the table node.

  6. Drag the master table node onto the item template region of the first DataRepeater control.

  7. Expand the master table node and select the detail node for the related table.

  8. Change the drop type of the detail table to Details by clicking Details in the drop-down list on the table node.

  9. Select this table node and drag it onto the item template region of the second DataRepeater control.

See Also

Tasks

How to: Display Bound Data in a DataRepeater Control (Visual Studio)

How to: Display Related Data in a Windows Forms Application

How to: Change the Appearance of a DataRepeater Control (Visual Studio)

Troubleshooting the DataRepeater Control (Visual Studio)

Reference

DataRepeater

Concepts

Introduction to the DataRepeater Control (Visual Studio)