Results 1 to 2 of 2

Thread: [2.0] ComboBox not updating its items

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    89

    [2.0] ComboBox not updating its items

    Hello,
    I have a combobox that is bound to a List<string>.
    I update my List<string> every now and then, adding new items or removing some. I expected the combobox item list would be automatically updated to reflect the changes but that's not happening. The item list always stays the same.

    Doing .Refresh() and .Update() on the combobox did not help. The only solution I've found so far is to unset the datasource, and then set it again. Behold the ugly code:

    mycombo.DataSource = null;
    mycombo.DataSource = myList

    This works but makes my combo flicker. Any better solution or explaination about why the itemlist is not updating?

    Thank you
    - mo! I said MOOOOOOO!!
    - ...yep, that's a cow, alright.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] ComboBox not updating its items

    Use a System.ComponentModel.BindingList instead of a System.Collections.Generic.List.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width