RowSource in Comboboxes?

sskelton

Member
Joined
Sep 1, 2011
Messages
7
Programming Experience
10+
I have been setting DataSource for a series of combo boxes to the same table as they all display the same options. However, when I ran the project, any change in any one combo box makes all the others 'flip' to the same selected value. This is obviously wrong.

In Access, you have 'Control Source' which is the db field that is bound to the combo box and 'Row Source' can be a query or whatnot that several combo boxes can run 'independently'.

Is there an equivalent option in VB.NET? I DO NOT want to manually enter the exact same options many times as that is hard to maintain, to say the least.

Just to repeat: it is not going to work to say DataSource = Row Source. if two combo boxes are set to the same data source, a selection in one automatically makes the other one select the same value. unless, of course, i am missing something.

Thanks in Advance!
 
The obvious option is to not use the same data source. When you bind a DataTable, it is actually the contents of its DefaultView that you see, which is a DataView. You can simply create a new DataView for each ComboBox and bind that directly:
myComboBox.DataSource = New DataView(myDataTable)
 
Thanks - that did it. the only place i can think of to do this is in the Form_Load event, so there's going to be a lot of code to handle initial form set-up.
 
Back
Top