master /detail form

obinna

New member
Joined
Oct 24, 2008
Messages
3
Programming Experience
1-3
hi guys,
am trying to build an application that would have a DataGridView and a details view. when a user selects an item from the the DataGridView , it shouls automatically show on the detailsview.and being able to use buttons to edit, save.
 
Do you wish this to be on the same form or two different forms?

One the same form I'd recommend using a SplitContainer, and setting it up to handle both sides/aspects of the DataTable.

Steps would be simple form this point on;.

  • Create a Dataset in the Dataset Designer
  • Create Form
    • in the Datasources window, you can open up the Dataset you create and select details/grid. Start with Details, and select the type of control you wish for each column in your table. The grab the whole Details link and drag it to one of the SplitContainer Panels. This will automatically add: DataSet, TableAdapter, BindingSource
    • Next, You can switch the selection for that table back to a Grid view and try to drop that onto the other panel, but that may create an additional binding source, or it may well use the one already on the form from the details view. (if it created a new one, delete it)
    • Add a Bindingnavigator to the top of the form, and make sure it doesn't add any other binding sources or what not.
  • modify bindings
    Simply put, set the datasource of the BindingNavigator, and the DataGridView to the binding Source that was originally added when you created the details view.

This here will defaultly allow you to load and navigate both the details view and the Grid view simultaneously on the same form. as you move in the grid, that updates the binding source, which is connected to all the detail's view controls as well as the navigator strip at the top, and vice versa with the strip.

There is a save button defaultly on the strip, but you will have to add the Cancel button.

Try playing around with this setup and let me know if you have any trouble working with the code after something like this is designed.
Cheers
 
Back
Top