DataGridView problem filter view

Duskan

New member
Joined
Mar 28, 2007
Messages
2
Programming Experience
5-10
Hi people, I am having a bit of trouble coding my Windows form. I have a DataGridView control which retrieves data from an Access database table. I can populate the DGV with all the records in the table using something like

dgv.DataSource = ds.Tables(0)

However my problem is that I do not wish to display all records. I have a combo box that displays all ID numbers in the table and once I click on the combo box I need the data grid view to only display that particular record. I have tried doing something like

dgv.DataSource = ds.Tables(0).Rows(combo.SelectedIndex)

That doesnt work at all however, anyone got any ideas on how I can get this working?

Thanks
 
DataGridView arent meant for showing only one row..
The combo is moot; youre using it to positionally alter the row, but combos shouldnt be used for this if the row set contains more than 20 elements (dont use a combo for more than 20 elements)

Your combo should bind thoguh a BindingSource, so should your DataGridView. Position alterations are thus reflected in both..

It still stands that using a DGV to show one row is a waste of functionality of a grid..

If youre talking about a master/detail relationship, then thats different and requires much more explaining..


-
For now, bind both the combo and the DGV through the same BindingSource (created by the IDE if you follow the correct procedure.. see the DW2 link in my sig, section displaying data on a form) and use them to see how it works. Youll get pretty tired of the combo when it contains > 20 items, and hopefully remove it..
 
Back
Top