var kba = new KBAlertz { "Launch Date" = "October 30th, 2013" }

Article ID: 967578 - View products that this article applies to.
Source: Microsoft Support

RAPID PUBLISHING

RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

Action

You develop a UserControl in Visual Studio 2005 or Visual Studio 2008 on a computer where the Font Dpi is set to 120 dpi. The UserControl contains constituent controls which are anchored to the bottom or the right of the UserControl design surface. The AutoScaleMode property of the UserControl is set to AutoScaleMode.Font. The UserControl is then placed on a Form with the AutoScaleMode set to Font.

Result

When the Form containing the UserControl  is displayed on a computer with the Font Dpi set to 96 dpi, the controls anchored to the right or bottom of the UserControl may not be displayed.

Cause

If the AutoScaleMode is set to Dpi for the UserControl and its containing Form, the AutoScaleDimensions are serialized in order to compute the AutoScaleFactor.  When the containing Form is displayed, the UserControl is initialized and scaling is performed on the UserControl. At this time, all the child controls of the UserControl are flagged so that they are not scaled again. Finally, when the Form calls ResumeLayout, layout and scaling are performed on the UserControl; however the UserControl's children are not scaled during this pass since they were flagged when scaling was performed previously.

Resolution

Set the UserControl's AutoScaleMode property to "Inherit".

More Information

Steps to Reproduce Problem
======================
1. On a computer with Visual Studio 2005 or Visual Studio 2008 installed, set the Font Dpi to 120. This may require a reboot of the computer.
2. Start Visual Studio and create a new Windows Forms application using Visual Basic or Visual C#.
3. Set the AutoScaleMode property to "Font" for Form1.
4. On the Project menu, click Add User Control. Select the default name "UserControl1" and click Add.
5. Set the AutoScaleMode property to "Font" for UserControl1.
6. Add two Button controls to the UserControl (Button1 and Button2).
7. Position Button2 at the bottom left of the UserControl design surface. The Location Property should be something like 0, 120, assuming that you have not changed the height of the UserControl.
8. Set the Anchor property for Button2 to "Bottom, Left".
9. Save UserControl1 and close it.
10. Build the project. This will allow UserControl1 to be visible on the Toolbox.
11. Select UserControl1 on the Toolbox, and drag and drop it onto Form1's design surface.
12. Set the Dock property to Fill for UserControl11. This will cause it to fill the entire containing Form.
13. Save Form1 and close it.
14. Build the project and run it. Note that you see the Form with the UserControl as expected.
15. Run the application on a computer has the Font Dpi set to 96. If you are changing this on the current computer, it may require a reboot.

Note that Button2 (the one anchored at the bottom of the UserControl) is not visible.

Further Information:

Automatic Scaling in Windows Forms
http://msdn.microsoft.com/en-us/library/ms229605.aspx

DISCLAIMER

MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

Properties

Article ID: 967578 - Last Review: February 5, 2009 - Revision: 1.0
APPLIES TO
  • Microsoft .NET Framework 2.0
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Team Suite
  • Microsoft Visual Studio 2008 Standard Edition
  • Microsoft Visual Studio 2008 Professional Edition
  • Microsoft Visual Studio Team System 2008 Team Suite
Keywords: 
kbnomt kbrapidpub KB967578