Redigera

Dela via


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

  1. 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