PC Review


Reply
Thread Tools Rate Thread

Adding new item in ComboBox with items in DataSource

 
 
marcobx@gmail.com
Guest
Posts: n/a
 
      30th Jan 2007
I have a ComboBox and a List of objects to popolate items.
I use the DataSource property and not the List collection:

List<foo> lst = 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add new items to combobox after the datasource is set Bill Nguyen Microsoft VB .NET 1 11th Apr 2006 08:04 AM
adding extra items on top of ComboBox DataSource DraguVaso Microsoft ADO .NET 6 5th Oct 2005 08:16 AM
adding extra items on top of ComboBox DataSource DraguVaso Microsoft Dot NET Framework Forms 6 5th Oct 2005 08:16 AM
adding extra items on top of ComboBox DataSource DraguVaso Microsoft Dot NET 6 5th Oct 2005 08:16 AM
adding extra items on top of ComboBox DataSource DraguVaso Microsoft VB .NET 6 5th Oct 2005 08:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 AM.