Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:18:40+00:00 2026-05-24T18:18:40+00:00

I have two lists. The first one is hard-coded and the contents never change.

  • 0

I have two lists. The first one is hard-coded and the contents never change. The second can be edited by the user to add, change and remove items:

public List<Item> DefaultItems = new List<Item>();
public BindingList<Item> UserItems = new BindingList<Item>();
...
MyTable.DataSource = UserItems;

I would like to bind the contents of both lists, one after the other, to a ComboBox and have it update automatically when the user edits the UserItems list.

The first part I can easily solve with something like:

public List<Items> AllItems
{
    get
    {
        List<Item> Items = new List<Item>();
        foreach (Item I in DefaultItems) Items.Add(I);
        foreach (Item I in UserItems) Items.Add(I);
        return Items;
    }
}
...
MyComboBox.DataSource = AllItems;

The problem is that when UserItems changes there is no notification that AllItems has changed so the contents of the combobox remain the same.

I then added an event that is generated when UserItems changes. Now my problem is how to force the ComboBox to refresh. Doing the following:

MyComboBox.DataSource = null;
MyComboBox.DataSource = AllItems;

results in the selecteditem becoming null and the selectedindex becoming -1, which I then have to handle in my code (temporarily remember the current item, restore it afterwards, etc.). It’s all becoming very messy and I’m sure there is a clever way of solving this. Is there?

thanks, Andy

UPDATE: I didn’t want to add yet more code and complexity just for this in the form of a third party assembly, so I just continued with my messy approach. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:18:42+00:00Added an answer on May 24, 2026 at 6:18 pm

    You need to use a collection that will notify the UI when the collection has been changed.

    You can either use the .NET provided BindingList class or, if you want to try something different, you could download the BindingListView class that will wrap your existing collections and provide the UI with the notification it needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists one displays cars company and the second one displays all
I have two lists. First one is a list of Tasks pulled from an
Absolute beginner question here. I have two lists in mathematica. The first one was
I have two drop down lists. Second one is populated based on value chosen
I have two list on my request on jsp. First one is productGroupName, and
This is two questions in one really... First, I have a list of 'tickets'.
I have two lists, one from 1 to 10 the other from 1 to
Suppose I have two lists of numbers in files f1, f2, each number one
I have two lists, one fake and one real, like: BEFORE // fake (list
I have two lists of strings that, in a better world, would be one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.