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

  • Home
  • SEARCH
  • 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 7887225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:31:25+00:00 2026-06-03T05:31:25+00:00

I have a Forms that is shown in a method called through Invoke because

  • 0

I have a Forms that is shown in a method called through Invoke because that method is called from a different thread. In the form I need to open I have a UserControl with a ComboBox in it. If the ComboBox.DropDownStyle is Simple the form.Show explodes throwing

InvalidOperationException: Cross-thread operation not valid: Control
‘comboBox1’ accessed from a thread other than the thread it was
created on.

If I set ComoBox.DropDownStyle in the default value (DropDown) I have no problem.

I now this is kind of hard to understand (even believe) so here there is a simplified example to reproduce it:

  1. Create a new winforms project.
  2. Create two forms and a user control.
  3. In the user control create a ComboBox.
  4. In the Form2 put an instance of the user control.
  5. In the Form1 code put this:

private Form form;
private delegate void ShowDelegate();
private ShowDelegate showDelegate;

private void Form1_Load(object sender, EventArgs e)
{
    showDelegate = Show;
    new Thread(Run).Start();
}

private void Run()
{
    form = new Form2();
    Invoke(showDelegate);
}

private void Show()
{
    form.Show();
}

Remember to set the event to Form1_Load.

  1. Run it and see it working.
  2. Change the ComboBox.DropDownStyle to Simple and see it not working!

Any help with this issue please?

  • 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-06-03T05:31:27+00:00Added an answer on June 3, 2026 at 5:31 am

    By simply moving

    form = new Form2();
    

    To your Show() method, it will work then.

    The Form gets initialized on the thread you start, it works then. But you might want to check the behavior in the long term …

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

Sidebar

Related Questions

I have a form that shows results from a database query, these results can
I have a form with a list that shows information from a database. I
Are forms that use the POST method required to have CSRF protection? I'm following
So I have a form that has a listbox that shows like a ledger.
In a typical business application it is quite common to have forms that are
I have some forms that communicate with server using AJAX for real reasons: cascade
I have many forms that use AJAX (w/ jQuery) for validation and data submission.
I have a few forms that use tiny mce. I have noticed recently that
I have web forms page that has 2 controls. A gridview and an associated
I'm creating a few web forms that have areas to them. Are fieldsets viable

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.