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 6216217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:11:43+00:00 2026-05-24T07:11:43+00:00

I am trying to populate a combobox in C#, but for some reason, the

  • 0

I am trying to populate a combobox in C#, but for some reason, the items do not appear.

public List<string> items
{
    set
    {
        combobox.Items.Clear();
        foreach(string s in value)
        {
            combobox.Items.Add(s);
        }
        combobox.Update();
    }
}

This seems like incredibly straightforward code. I simply cannot see what is wrong.
It is being called like this:

private void StoreNames(List<string> names)
{
    if (selectionForm.InvokeRequired)
        selectionForm.Invoke((MethodInvoker)delegate { selectionForm.items = names; });
    else
        selectionForm.items = names;
}

Interestingly, it seems to work when InvokeRequired returns true, but does not work when it returns false.

EDIT:
I discovered that selectionForm.IsHandleCreated is currently false. This is causing InvokeRequired to return false, but is also why calling the setter regularly isn’t working. I don’t have any idea why IsHandleCreated is set to false. The Form has been Show()n.

  • 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-24T07:11:44+00:00Added an answer on May 24, 2026 at 7:11 am

    Not sure why your code isn’t working – I tried it and it works just fine.

    However, below is some more straightforward code which also works – you may find that doing it this way instead makes your problem go away. This does presume that there is not other reason why you need to go through that property – that is quite an unusual way of doing things.

    public void StoreNames(List<string> input)
    {
        if (comboBox1.InvokeRequired)
            comboBox1.Invoke((MethodInvoker)delegate {
                StoreNames(input);
            });
        else
        {
            comboBox1.Items.Clear();
            comboBox1.Items.AddRange(input.ToArray());
        }
    }
    

    Here we just pass the list straight to the items.AddRange() method on the comboBox.

    I suspect this won’t work for you – something else is going on, but I have tried it both from a backgroundworker (where InvokeRequired is true) and from the main UI thread.

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

Sidebar

Related Questions

I trying to populate the dropdown list when page was loaded.But it is not
I am trying to populate a ListView ....but I cant add 2 string values
I'm trying to bind a ComboBox to an ObservableCollection<MyType> but it's not working as
I am trying to populate a datagrid with one column as a combobox but
I am trying to use a dataContext to populate a comboxbox but always got
I'm trying to populate a ComboBox programatically. I am creating ComboBoxItems and would like
I am using ExtJS (3) and just trying to populate a combobox/drop down using
I've got a DataGrid with 6 columns: ComboBox;ComboBox;CheckBox;CheckBox;CheckBox;TextBox I'm trying to populate this DataGrid
I am trying to populate a List<Image> by reading the name of the each
hi i am trying to populate a combo box in struts 1.2 but i

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.