484 Part IV Database and Web Programming
If you want to run your program now and have the two data grid view controls linked,
you don’t need to add any additional controls to your project. With one navigation
bar, the two tables will be linked and both will scroll automatically, even though they
display slightly different fields. Let’s see how this works.
- Click the Save All button to save your changes.
- Click the Start Debugging button on the toolbar.
Visual Studio runs the DataGridView Sample program in the IDE. You see two data grid
view objects on the form, as shown in the following screen shot:
- Use the navigation bar to start scrolling through the Faculty table records.
You can see that the two data grid view objects are linked, because they share the
same table and underlying data adapter and binding navigator. This is a feature of the
way dataset navigation works in this particular implementation; however, if you choose
to display two separate database tables, you can add a second navigation bar and
move through the records separately.
- Use the top scroll bar to move through the contents of the top data grid view object on
its own.
The scroll bars allow you to view the two data grid view objects independently, so you
always don’t have to be looking at the records for the same employee. - When you’re finished experimenting with the two data grid view objects, click the Close
button to close the DataGridView Sample application.
You can perhaps appreciate how useful two data grid view objects might be for the user who
wants to compare two very large tables of information. If the data is further filtered by SQL
SELECT statements, the application quickly becomes quite powerful.