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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:07:56+00:00 2026-05-10T18:07:56+00:00

I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;

  • 0

I have a little demonstration below of a peculiar problem.

using System; using System.Windows.Forms;  namespace WindowsApplication1 {     public class TestForm : Form     {         private System.Windows.Forms.TabControl tabControl1;         private System.Windows.Forms.TabPage tabPage1;         private System.Windows.Forms.TabPage tabPage2;         private System.Windows.Forms.TextBox textBox1;          public TestForm()         {             //Controls             this.tabControl1 = new System.Windows.Forms.TabControl();             this.tabPage1 = new System.Windows.Forms.TabPage();             this.tabPage2 = new System.Windows.Forms.TabPage();             this.textBox1 = new System.Windows.Forms.TextBox();              // tabControl1             this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)                         | System.Windows.Forms.AnchorStyles.Left)                         | System.Windows.Forms.AnchorStyles.Right)));             this.tabControl1.Controls.Add(this.tabPage1);             this.tabControl1.Controls.Add(this.tabPage2);             this.tabControl1.Location = new System.Drawing.Point(12, 12);             this.tabControl1.Name = 'tabControl1';             this.tabControl1.SelectedIndex = 0;             this.tabControl1.Size = new System.Drawing.Size(260, 240);             this.tabControl1.TabIndex = 0;             this.tabControl1.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl1_Selected);              // tabPage1             this.tabPage1.Controls.Add(this.textBox1);             this.tabPage1.Location = new System.Drawing.Point(4, 22);             this.tabPage1.Name = 'tabPage1';             this.tabPage1.Size = new System.Drawing.Size(252, 214);             this.tabPage1.TabIndex = 0;             this.tabPage1.Text = 'tabPage1';              // tabPage2             this.tabPage2.Location = new System.Drawing.Point(4, 22);             this.tabPage2.Name = 'tabPage2';             this.tabPage2.Size = new System.Drawing.Size(192, 74);             this.tabPage2.TabIndex = 1;             this.tabPage2.Text = 'tabPage2';              // textBox1             this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)                         | System.Windows.Forms.AnchorStyles.Right)));             this.textBox1.Location = new System.Drawing.Point(6, 38);             this.textBox1.Name = 'textBox1';             this.textBox1.Size = new System.Drawing.Size(240, 20);             this.textBox1.TabIndex = 0;              // TestForm             this.ClientSize = new System.Drawing.Size(284, 264);             this.Controls.Add(this.tabControl1);             this.Name = 'Form1';             this.Text = 'Form1';         }          //Tab Selected         private void tabControl1_Selected(object sender, EventArgs e)         {             this.Text = 'TextBox Width: ' + this.textBox1.Width.ToString();         }     }      //Main     static class Program     {         static void Main()         {             Application.Run(new TestForm());         }     }  } 

If you run the above C# code you will have a small form containing a tabcontrol. Within the tabcontrol is a texbox on the first tab. If you follow these steps you will see the problem:

  1. Select tabPage2 (textBox1’s width is reported in the form title)
  2. Resize the form
  3. Select tabPage1 (The wrong textBox1 width is reported)

Any ideas what is going on here? The textbox is obviously bigger than what is being reported. If you click again on tabPage2 the correct size is then updated. Obviously there is an event updating the width of textBox1. Can i trigger this when tabPage1 is selected?

  • 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. 2026-05-10T18:07:57+00:00Added an answer on May 10, 2026 at 6:07 pm

    Firstly, thanks for the complete program – it made it much easier to work out what was going on!

    While the textbox isn’t visible, it isn’t resized. When you select tabPage1, the Selected event fires before the controls become visible and the textbox gets laid out again.

    Now, that’s why it’s happening – but what’s your real situation? If you actually want to capture the size of controls changing, subscribe to their Resize events. If not, could you explain more about what you’re trying to achieve?

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

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer HTMLTable is an abstract class. FlexTable extends this class as… May 11, 2026 at 2:44 pm
  • added an answer Check out this post. It overrides the binding method for… May 11, 2026 at 2:44 pm
  • added an answer I've solved this by leveraging the fact that any CLR… May 11, 2026 at 2:43 pm

Related Questions

I've never really had the need to use any drag functions until now, so
I have a little dilemma that maybe you can help me sort out. I've
I have a little game written in C#. It uses a database as back-end.
I have a little problem with a Listview. I can load it with listview

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.