System.Windows.Forms.Label.PreferredWidth Property

Gets the preferred width of the control.

Syntax

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public virtual int PreferredWidth { get; }

Value

Documentation for this section has not yet been entered.

Remarks

This property returns the length of the text string, but does not take line wrapping into consideration. For example, a text string that measures 300 pixels wide could be displayed as three lines in a System.Windows.Forms.Label that is only 100 pixels wide. The Label.PreferredWidth property still returns 300 pixels. You can use this property, along with the Label.PreferredHeight property, to ensure that the text in the System.Windows.Forms.Label control is displayed properly. You can use the Label.AutoSize property to automatically adjust the height and the width of the System.Windows.Forms.Label control based on the text and font size.

Note:

If the Label.BorderStyle property of the System.Windows.Forms.Label control is set to BorderStyle.None, the value returned by Label.PreferredWidth property will be larger due to the lack of borders.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0