Monday, November 23, 2009

Multiple Combobox with same datasource

One day Mr. Jodha asked me for solution for his prolem.
-he used select query and got all data in datatable.
-then he made that datatable as datasource for two combobox which will show different
fields of that table
-but the proble is that when he select value from one combobox then the value of same record in second
combobox get selected.

and that is main problem.
Solution:Their exist very simple solution for this kind of problem
make a new bindingcontext for every combobox
combobox1.BindingContext = New BindingContext()
combobox2.BindingContext = New BindingContext()

When they are created, they inherit from the control that is hosting
them. Since you didn't specify it, it are all using the context of the
control/form that they are hosted in, and that's why when you change one
combo box, they all change.

Share This!

No comments:

Powered By Blogger · Designed By Seo Blogger Templates