Form.AutoScale 属性



此 API 现已过时。

获取或设置一个值,该值指示窗体是否调整其大小以适合该窗体上使用的字体高度,以及是否缩放其控件。Gets or sets a value indicating whether the form adjusts its size to fit the height of the font used on the form and scales its controls.

 property bool AutoScale { bool get(); void set(bool value); };
[System.Obsolete("This property has been deprecated. Use the AutoScaleMode property instead.")]
public bool AutoScale { get; set; }
member this.AutoScale : bool with get, set
Public Property AutoScale As Boolean


如果窗体根据分配给它的当前字体自动缩放本身及其控件,则为 true;否则,为 falsetrue if the form will automatically scale itself and its controls based on the current font assigned to the form; otherwise, false. 默认值为 trueThe default is true.




AutoScale 已过时,已保留下来是为了向后兼容。The AutoScale is obsolete and has been retained for backward compatibility. 未过时的替代项为 ContainerControl.AutoScaleModeThe non-obsolete alternative is ContainerControl.AutoScaleMode. 有关自动缩放的详细信息,请参阅Windows 窗体中的自动缩放For more information about automatic scaling, see Automatic Scaling in Windows Forms.

您可以使用此属性来允许您的窗体及其控件基于字体中的更改自动进行调整。You can use this property to allow your form and its controls to automatically adjust based on changes in the font. 这在应用程序中可能会很有用,其中,字体可能会根据指定用于 Windows 的语言而增加或减少。This can be useful in applications where the font might increase or decrease based on the language specified for use by Windows.

若要获取窗体将自动缩放到的大小,请使用 AutoScaleBaseSize 属性。To obtain the size the form will auto scale to, use the AutoScaleBaseSize property. 如果要根据特定字体确定窗体将自动缩放到的大小,请使用 GetAutoScaleSize 方法。If you want to determine the size the form will auto scale to based on a specific font, use the GetAutoScaleSize method.