Combo Box Update Problem

  • Thread starter Thread starter db_from_mn
  • Start date Start date
D

db_from_mn

I have a combo box in which I've set the DataSource to an
instance of an ArrayList. The contents of the ArrayList
is managed in a timer control's timer_elapsed event
handler. The number of items in the ArrayList may
increase or decrease. When the contents of the ArrayList
changes, I try to update the choices in the combo box. I
can get the list to display correctly when items are
initially added to the ArrayList, but after that, I can't
change the list. I've tried a variety of things,
including the combo box's Update() and Refresh() methods.
Nothing I've tried works.
Can someone help me out?
Thanks in advance,
db_from _mn
 
db_from_mn,

The reason this doesn't work is because the ArrayList doesn't implement
the IBindingList interface. This interface is used in data binding to allow
binders to know when the underlying list changes. In order to get around
this, you should create a class that either wraps the ArrayList, or
subclasses ArrayList and implements IBindingList. The ListChanged event on
the interface will let binders know that the list has changed.

Hope this helps.
 
Hi Nick,
Thanks for the help. I'll give it a try.
Dennis
-----Original Message-----
db_from_mn,

The reason this doesn't work is because the ArrayList doesn't implement
the IBindingList interface. This interface is used in data binding to allow
binders to know when the underlying list changes. In order to get around
this, you should create a class that either wraps the ArrayList, or
subclasses ArrayList and implements IBindingList. The ListChanged event on
the interface will let binders know that the list has changed.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a combo box in which I've set the DataSource to an
instance of an ArrayList. The contents of the ArrayList
is managed in a timer control's timer_elapsed event
handler. The number of items in the ArrayList may
increase or decrease. When the contents of the ArrayList
changes, I try to update the choices in the combo box. I
can get the list to display correctly when items are
initially added to the ArrayList, but after that, I can't
change the list. I've tried a variety of things,
including the combo box's Update() and Refresh() methods.
Nothing I've tried works.
Can someone help me out?
Thanks in advance,
db_from _mn


.
 
Back
Top