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.
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.
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.
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.
Set theÂ UserControl's AutoScaleMode property to "Inherit".
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.
Automatic Scaling in Windows Formshttp://msdn.microsoft.com/en-us/library/ms229605.aspx
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.
Article ID: 967578 - Last Review: February 5, 2009 - Revision: 1.0
- 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
|kbnomt kbrapidpub KB967578|