Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

combobox refresh after adding to arraylist

1 view
Skip to first unread message

Felix Wu(MS)

unread,
Aug 12, 2002, 2:12:51 AM8/12/02
to
Hi,

The ComboBox will not update when you update the DataSource unless that DataSource implements IBindingList. However, the 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. I hope it may help:

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

Alternatively, we can workaround this problem by resetting the data binding each time you change the ArrayList object:

comboBox1.DataSource=null;
comboBox1.DataSource=arrayList1;
..

Hope this helps.

Regards,

Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Need quick answers to questions like these? The Microsoft Knowledge Base provides a wealth of information that you can use to troubleshoot a problem or answer a
question! It's located at http://support.microsoft.com/support/c.asp?M=F>.


--------------------
>From: newsg...@yahoo.com
>Newsgroups: microsoft.public.dotnet.languages.csharp
>Subject: combobox refresh after adding to arraylist
>Date: 8 Aug 2002 20:19:26 -0700
>Organization: http://groups.google.com/
>Lines: 24
>Message-ID: <70dd91df.02080...@posting.google.com>
>NNTP-Posting-Host: 64.29.67.226
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1028863166 10664 127.0.0.1 (9 Aug 2002 03:19:26 GMT)
>X-Complaints-To: groups...@google.com
>NNTP-Posting-Date: 9 Aug 2002 03:19:26 GMT
>Path: cpmsftngxa08!cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.gamma.ru!Gamma.RU!isdnet!sn-xit-02!sn-xit-06!sn-xit-04!
supernews.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa08 microsoft.public.dotnet.languages.csharp:82960
>X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
>
>Windows Forms...
>
>I have a combobox that is bound to an arraylist. I initially populate
>the arraylist with objects (person object - ID and Name properties).
>The combobox is bound during the formload event. The combobox
>populates correctly.
>
>I have a button that allows the user to add a another person object to
>the arraylist. The arraylist adds the person object correctly,
>however, I can't seem to get the combobox to display the change. I
>have tried the update and refresh methods, however, it still won't
>display the change.
>
>Another person had a workaround by doing the following...
>
>combobox.SuspendLayout();
>combobox.Visible = false;
>combobox.Visible = true;
>combobox.ResumeLayout();
>
>This workaround actually works, however, I am wondering if there is a
>more elegant way to do this.
>
>Any suggestions?
>


0 new messages