467,180 Members | 1,029 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,180 developers. It's quick & easy.

Add an item into only one combobox which is binded with a list bound to multiple ctrl

I've a list of items which I bound to multiple combo boxes.
In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo boxes...How should I do that...
As when I'm trying to add an item...it is being shown in all the combo boxes.

Expand|Select|Wrap|Line Numbers
  1. private void FillMethod() 
  2.            BindingSource bs = new BindingSource();
  3.             BindingSource bs1 = new BindingSource();
  4.             BindingSource bs2 = new BindingSource(); 
  5.  
  6.             List<string> list = Filldata();
  7.             bs.DataSource = list;
  8.             bs1.DataSource = list;
  9.             bs2.DataSource = list; 
  10.  
  11.            comboBox1.DataSource = bs;
  12.            comboBox2.DataSource = bs1; 
  13.            comboBox3.DataSource = bs2;
  14.  
  15.           combobox1.items.add("sai");
  16. }
  17.  
Apr 14 '09 #1
  • viewed: 2935
Share:
4 Replies
100+
Expand|Select|Wrap|Line Numbers
  1. private void FillMethod() 
  2.            bs.DataSource = list;
  3.            comboBox1.DataSource = bs.Clone();
  4.            comboBox2.DataSource = bs.Clone(); 
  5.            comboBox3.DataSource = bs.Clone();
  6.  
  7.           combobox1.items.add("sai");
  8. }
  9.  
I tested none, but I'm sure that DataSource of each ComboBox now has a different copy of list.
Apr 14 '09 #2
We don't have Clone method in binding source.

My requirement is adding one item in only one combo box and it should not reflect in our combo boxes...
Apr 15 '09 #3
100+
OK.
You may do this.
Expand|Select|Wrap|Line Numbers
  1. private void FillMethod() 
  2.            comboBox1.DataSource = list.Clone();
  3.            comboBox2.DataSource = list.Clone(); 
  4.            comboBox3.DataSource = list.Clone();
  5.  
  6.           combobox1.items.add("sai");
  7. }
It's not about Clone Method. To not affect on the other DataSource they've to be different.
Apr 16 '09 #4
tlhintoq
Expert 2GB
I've a list of items which I bound to multiple combo boxes.
In the due course in the code...I had to add an item into one combo box...but I don't want it to be reflected into any other combo boxes...How should I do that...
As when I'm trying to add an item...it is being shown in all the combo boxes.
As it would be. Same source equals same result. If you want different result then you need a different source.

Walk it through in your mind for a moment... How can you envision a way to tell the computer to filter a single list so that some items are in combobox1 and others in combobox3? All items that start with the letter 'g'? Only items 1,4,8?

Whatever criteria you can devise for the filtering would have to be done first... get those results... then add those results to the Combobox.Items collection directly instead of trying to do it with binding.
Apr 17 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Phil | last post: by
1 post views Thread by TheMadHatter | last post: by
4 posts views Thread by Jerad Rose | last post: by
10 posts views Thread by =?Utf-8?B?UiBSZXllcw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.