2008-10-13 151 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