multiple comboBox one array datasource. help...

G

Guest

I have an array of a custom obj which I am trying
to use in multiple comboBoxes without creating multiple
copies, but if I put the datasource of the comboboxes to
the same array, then at runtime if I pick change a combobox,
all of them change to that value. I am guessing that it is
because all the comboboxes are using the same Ilist interface,
and the behind-the-sceens variables.

Now, I could create my own wrapper class to wrap the
array, but I was hoping that there was already one hiding
in plan sight in the frameworks.

Thanks in advance for all help on the issue.
 
B

Bart Mermuys

Hi,

TheMadHatter said:
I have an array of a custom obj which I am trying
to use in multiple comboBoxes without creating multiple
copies, but if I put the datasource of the comboboxes to
the same array, then at runtime if I pick change a combobox,
all of them change to that value. I am guessing that it is
because all the comboboxes are using the same Ilist interface,
and the behind-the-sceens variables.

Now, I could create my own wrapper class to wrap the
array, but I was hoping that there was already one hiding
in plan sight in the frameworks.

If the two ComboBoxes SelectedValue isn't bound to a common table, list or
object then you can set a different BindingContext for each ComboBox:

comboBox1.BindingContext = new BindingContext();
comboBox2.BindingContext = new BindingContext();

But you could also use a wrapper (like you mentioned). I don't think there
anyhing available in NET1.1, but you could create one yourself (eg. based on
IListSource to keep it simple).

In NET2.0 you just put a different BindingSource between the List and the
ComboBox.

HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top