This article has been archived. It is offered "as is" and will no longer be updated.
You minimize a form that has a control, and then you change the size of the control while the form is minimized. When you restore the form, the control size values that you set while the form was minimized are not preserved.
This bug occurs when you set the Anchor property of the control to Top, Bottom, Left, Right and you set the size of the control at run time.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Steps to Reproduce the Behavior
In Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, start a new Microsoft Windows application by using Microsoft Visual Basic .NET, Microsoft Visual Basic 2005, Microsoft Visual C# .NET, or Microsoft Visual C# 2005.
By default, Form1 is created.
Add a TextBox control to Form1.
Right-click TextBox1, and then click Properties.
In the Properties dialog box, set the Multiline property to True.
Set the Size property to 200,200.
Set the Anchor property to Top, Bottom, Left, Right.
Add a Button control to Form1.
Add the following code to the Button1_Click event handler:
Visual Basic .NET or Visual Basic 2005 Code
'Minimize the form.Me.WindowState = FormWindowState.Minimized'Set the size of the TextBox in the Minimized form.Me.TextBox1.Size = New Size(100, 100)Console.WriteLine("size of TextBox1 on the minimized form is:" & TextBox1.Size.ToString)'Display the form in the normal state.Me.WindowState = FormWindowState.NormalConsole.WriteLine("size of TextBox1 after bringing to Normal state is:" & TextBox1.Size.ToString)
Visual C# .NET or Visual C# 2005 Code
//Minimize the form.this.WindowState = FormWindowState.Minimized;//Set the size of the TextBox in the Minimized form.this.textBox1.Size = new Size(100, 100);Console.WriteLine("size of TextBox1 on the minimized form is:" + textBox1.Size.ToString());//Display the form in the normal state.this.WindowState = FormWindowState.Normal;Console.WriteLine("size of TextBox1 after bringing to Normal state is:" + textBox1.Size.ToString());
In Solution Explorer, right-click WindowsApplication1, and then click Properties.
On the Build menu, click Build Solution.
On the Debug menu, click Start.
The size of the TextBox is not restored. Notice the output in the Output window.
For more information, visit the following Microsoft Developer Network (MSDN) Web site: