CollectionBase ->ComboBox.DataSource -- Updates don't show up?

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

I have inhereted CollectionBase to store a data that is continuously
(every few seconds) updated (entries added and removed).

I need to show to current items in the Collection via a ComboBox (so
the user can pick the one he wants to watch). So I thought I could do:

comboBox.DataSource = myCollection;

Then any time I do an Add() to myCollection the new item would appear
in the ComboBox. I set up a test using a Timer() which adds items and
I never see the new items in the ComboBox.

What am I missing?

Thanks,
John
 
You probably need to do an invoke. I've found all kinds of things with
timers that indicate that they're running in another thread and do nasty
things to controls if you update them on the event.

this.Invoke(MethodInvoker(MethodName()));

James Hancock
 
Hello John,

Thanks for your post. As I understand, the problem you are facing is that
the ComboBox will not be updated after underlying DataSet is changed.
Please correct me if there is any misunderstanding. I now share the
following information with you:

Generally speaking, a ComboBox will not update when you update the
DataSource unless that DataSource implements IBindingList. For example,
ArrayList does not support IBindingList interface and no change
notification is fired for the changes made in the ArrayList object. The
following document provides a simple implementation of the IBindingList
interface:

IBindingList Interface
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemComponentModel
IBindingListClassTopic.asp

The simplest method to workaround this problem is resetting the data
binding each time you change the myCollection object:

comboBox.DataSource=null;
comboBox.DataSource=myCollection;

Please check it on your side and let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top