2008-10-13 156 views
26

所以我想弄清楚窗体的AutoScaleMode属性如何可能有助于支持与我的工作开发机器不同的字体或DPI的系统。支持DPI和默认字体更改

从SDK:

AutoScaleMode枚举

公共枚举AutoScaleMode

None 
    Automatic scaling is disabled.  
Font 
    Controls scale relative to the dimensions of the 
    font the classes are using, which is typically the 
    system font. 
Dpi  
    Controls scale relative to the display resolution. 
    Common resolutions are 96 and 120 DPI. 

默认情况下.NET 2.0形式使用AutoScaleMode.Font。

因此,我在Windows XP,Tahoma 8 pt,96 DPI开发机器上设计了一个样本表单。然后,我尝试过了一个

  • 14点的Segoe UI 96 DPI机上
  • 14点的Segoe UI 150个DPI机

结果并不令人鼓舞,因为你可以在这个截图中看到:

的AutoScaleMode属性未设计用于为支持不同的字体或DPI设置的NET的形式。那么支持不同字体和DPI设置的正确方法?

回答

5

正确的方法是缩放控件,表单本身和其中的文本。这听起来非常复杂,但布局控件(TableLayoutPanel和FlowLayoutPanel)与AutoSize属性结合使用,使其难度大大降低。

+0

布局面板在上述形式中不会有任何用处,事情已经使用锚定来布置。 – 2008-10-14 16:46:01