Data Access: Build a Master-Details Windows Forms App
This sample shows you how to build a master-details application. This
common type of data-bound form is useful for navigating through records and
viewing various levels of detail for the data related to each
record.
Featured Highlights
-
See how a single DataSet can be filled with four DataTables and bound to
various controls that are kept in sync with each other by the Form's
BindingContext object.
-
View two types of Master-Details interfaces:
-
Display data in two separate DataGrid controls, one for the Master
"Orders" table, and another for the Details "Order Details" table.
-
Display data in a single DataGrid, using the DataGrid's intrinsic
node-like controls for drilling down into the order details.
-
Navigate back and forth through the records by clicking navigational buttons or
by pressing arrow keys or the Home/End keys.
-
See how custom formatting can be applied to data bound controls.
Requirements
This application requires the release version of Visual Studio .NET Professional
(or greater) and access to the Northwind database residing in SQL Server or the
Microsoft Data Engine (MSDE). To install MSDE, do the following:
1. Open the Start menu, click Programs, click Microsoft .NET
Framework SDK, and then click Samples and Quickstart Tutorials.
2. Click "Step 1: Install the .NET Framework Samples Database".
3. Open a command window, and CD to
\Samples\Setup This is typically : C:\Program Files\Microsoft
Visual Studio .NET\FrameworkSDK\Samples\Setup
4. Type: osql -E -S (local)\NetSDK -i InstNwnd.sql
Running the Sample
Simply press F5.
To view the alternate
Master-Details interface, uncomment the line labeled OPTIONAL in the CreateDataSet method.
See Also
Creating a Master Detail Form
DataRelation Objects
DataSets