The heart of a first-class relational application is the
capability to display parent-child relationships. Visual
Studio 2005 presents a quite flexible tool to help rapid
development of this functionality. In the Data Sources pane if
you increase the tables, you will see under the fields, an
entry for each child relationship of the table. In our
example, increasing the Orders table node, you will see an
entry for the relationship to the Order Details table. If you
choose the representation and drag the relation node to the
form, VS believe you want a master-detail arrangement and will
created the needed relations for you.
VS will add a new module to the form for the table and a
table adapter to fill up the table on form load. The Smart
Data tag will expand you can click on the arrow in the higher
right of the grid control to explain a number of properties
and actions used for the control. The "Choose Data Source"
should be set to the new binding basis based on the relation
among the tables. This is every one that is needed to set the
detail grid to connection with the master record. If you seem
at the properties, you will see that the Data Source used for
the newly added Binding Source is the Data Member in the
If you compile and run the project presently, you will
observe the linking between the master and detail parts. But
the grid wants some editing to create it show productive data.
You will require replacing the with a combo box to show the
name of the product in its place. This will require one more
binding basis to be added to the form. Drag a Binding Source
component from the Data part of the Toolbox, name it and put
the Data Source property to Data Member property to the
At the present expand the Smart Tag on the control once
more look at the Properties pane and click the "Edit Columns"
action. This permits you to edit breadth and method of
columns, reorder the columns, and add or delete columns. You
can delete any columns that are not required and hide the
Primary Key and Foreign Key fields. You should also convert
the column from a Text Box control to a Combo Box control to
show the value of Product Name. Set the Data Source property
to Products, and the Display Member to the Value Member in the
When the Order feature Binding Source was added, VS too
added the following lines of code to the event to fill the
Order Detail table.
That is every one we require to do. We
can construct and run our application by pressing F5 selecting
and then "Start Debugging from the Debug Menu. Here is an
example of the last form running. See that the Navigation Bar
let us to move between records and the Order Detail
information is connected to the Orders record selected. Also
in the navigation bar is a yellow asterisk switch to create a
new record, a red X switch to delete the present record, and a
diskette button to save changes.
Whereas VS 2003 offered one stiff wizard for RAD building of
master-detail form, VS 2005 has an infrastructure to permit
RAD construction of a thick variety of form styles. The Data
Sources tool is a welcome development to Visual Studio.