How to: Size a Windows Forms Label Control to Fit Its Contents
The Windows Forms Label control can be single-line or multi-line, and it can be either fixed in size or can automatically resize itself to accommodate its caption. The AutoSize property helps you size the controls to fit larger or smaller captions, which is particularly useful if the caption will change at run time.
To make a label control resize dynamically to fit its contents
- Set its AutoSize property to
true
.
If AutoSize is set to false
, the words specified in the Text property will wrap to the next line if possible, but the control will not grow.
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET Desktop feedback