Datagrid navigation problem

gate7cy

Well-known member
Joined
May 11, 2009
Messages
119
Programming Experience
3-5
I have on my form two datagridviews that correspond to the same table. They are both databound. They have been created automatically through dragging them from the datasources windows. One is datagridview and the other datagridview1. When ever I navigate through a datagrid the corresponding row on the other grid changes as well. I do not want this. Also I want to be able to fill and use each datagrid indepentent from each other. To fill a datagridview on load I use this code

VB.NET:
Me.AllServicesTableAdapter.workstation(Me.Database2DataSet.AllServices)

This code does not let me choose which datagrid to fill. How to solve my issuea.

I am using VS 2008/VB with Access 2007

Thanks for all the replies
 
Are you saying that you want the two grids to be totally independent, i.e. editing data in one doesn't affect the other, or just that you want navigation to be independent, i.e. edits affect both grids but different rows can be selected in each?
 
I want the navigation to be independent and aswell the filtering of the data done on the datagrid to be different. i.e. to be able to use different parameter queries to fill the grids
 
If you want completely separate data then you simply need two DataSets and populate the two separate DataTables. If you want one set of data then you need to create two new DataViews from the one DataTable. You can then bind those two DataViews and they will be able to be filtered, sorted and navigated independently.
 
Look at your form in design mode
Look in the panel at the bottom
See Database2Dataset? Copy and paste it (duplicate)
See AllServicesBindingSOurce? duplicate that too
Duplicate your grid

Bind your new grid to the new bindingsource (datasource property)
Bind your new bindingsource to your new dataset (leave the datamember alone, just edit the datasource property)

Use one tableadapter to fill one dataset table or the other depending on which grid is to fill

Give everything more meaningful names than Database2Dataset2.. 3... etc
 

Latest posts

Back
Top