By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

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

P: 9
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
Share this Question
Share on Google+
4 Replies


100+
P: 344
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

P: 9
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+
P: 344
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 2.5K+
P: 3,525
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.