LabelControl.AutoSizeMode Property

Gets or sets the direction in which the label grows to display its entire contents.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DefaultValue(LabelAutoSizeMode.Default)]
[DXCategory("Layout")]
public LabelAutoSizeMode AutoSizeMode { get; set; }
<DefaultValue(LabelAutoSizeMode.Default)>
<DXCategory("Layout")>
Public Property AutoSizeMode As LabelAutoSizeMode

Property Value

Type Default Description
LabelAutoSizeMode

Default

The direction in which the label grows to display its entire contents.

Remarks

If the AutoSizeMode property is set to LabelAutoSizeMode.Horizontal, the label automatically changes its width to display its entire contents. Its size depends only on the length of the text and on the font settings, the label cannot be resized by a user.

If the AutoSizeMode property is set to the LabelAutoSizeMode.Vertical value, the label automatically changes its height to display its entire contents. In this instance, a user can change the label's width while its height automatically adjusts to fit the label's text.

The code sample below illustrates a label control that grows horizontally until 300 pixels, after which it wraps the text to next line(s).


int nMaxWidth = 300;

labelControl1.AutoSizeMode = LabelAutoSizeMode.Vertical;
labelControl1.Width = nMaxWidth;
labelControl1.Text = "This is an example of a label control that stretches vertically to hold a long text.";
See Also