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

Adding new item in ComboBox with items in DataSource

P: n/a
I have a ComboBox and a List of objects to popolate items.
I use the DataSource property and not the List collection:

List<foolst = new List<foo>;
//add elements into the list
//...
comboBox1.DataSource = lst;

This work fine, items appear.
Now I have a button near the combo box and I want to add a new element
in the list when the user click the button.

If I try to add a new item in the comboBox1.List collection the
framework returns the error "Items collection cannot be modified when
the DataSource property is set.", so I try to add the new item in the
List linked to DataSource property:

lst.Add(new foo);

comboBox doesn't return any error, but the new item doesn't appear.

HOW CAN I FORCE COMBOBOX TO REFRESH THE ITEMS? OR ANY NEW IDEA TO
ADDING AN ITEM AFTER THE LIST IS POPOLATED?

Thanks!
Marco

Jan 30 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.