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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:24:51+00:00 2026-06-05T20:24:51+00:00

I am having a strange problem with the .NET TabControl in C# (Visual Studio

  • 0

I am having a strange problem with the .NET TabControl in C# (Visual Studio 2010). Start a Windows Forms Application. Add a tab control and a button. Add two different labels to the two tab pages so you can differentiate them. The purpose of the button is just to act as a next button; subscribe to the its Click event with the code:

tabControl1.SelectTab(1);

Let’s assume the user entered something wrong on the first tab, so when they try to go to the second tab we want to send them back, so subscribe to the tab control’s SelectedIndexChanged event with the code:

if(tabControl1.SelectedIndex == 1)
{
    tabControl1.SelectTab(0);
}

Now run the program and click the button. You will notice that as judged by the highlighted tab at the top, the first tab page is the one that appears to be selected, as you’d expect. However, as judged by the tab page that actually appears in the body of the tab control, it’s still the second tab page that shows up! Calls to various controls’ Focus(), Update(), and Refresh() functions don’t seem to help. What is going on here?

  • 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-05T20:24:53+00:00Added an answer on June 5, 2026 at 8:24 pm

    I repro. This is a generic problem with event handlers, you can confuse the stuffing out the native Windows control by jerking the floor mat like that. TreeView is another control that’s very prone to this kind of trouble.

    There’s an elegant and general solution for a problem like this, you can use Control.BeginInvoke() to delay the command. It will execute later after the native control is done with the event generation and all side-effects have been completed. Which solves this problem as well, like this:

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) {
            if (tabControl1.SelectedIndex == 1) {
                this.BeginInvoke(new Action(() => tabControl1.SelectTab(0)));
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a strange problem with IIS, asp.net and ODBC. My application is driven
I am having a strange problem. I am working on a .net windows project
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
I'm having a strange problem in Visual Studio 2008 where my Pending Checkins window
I'm having a strange problem with adding a UINavigationController to my iPhone application. I
I am having a rather strange problem, I deployed 2 .NET applications on my
I'm using Visual Studio 2010 to write a simple C#/.NET GUI app, wherein I
I'm having a very difficult and strange problem Authenticating with System.Net.Mail.SMTPClient. I need to
I'm having a strange problem with new Entity Framework for .NET 4 I have
i am having a strange problem, while calling ajax jquery in asp.net.. i am

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.