Gets the preferred width of the control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
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 Label that is only 100 pixels wide. The property still returns 300 pixels. You can use this property, along with the PreferredHeight property, to ensure that the text in the Label control is displayed properly. You can use the AutoSize property to automatically adjust the height and the width of the Label control based on the text and font size.
The following code example demonstrates how to create a Label control that has a three-dimensional border and an image displayed using the ImageList and ImageIndex properties. The control also has a caption with a mnemonic character specified. The example code uses the PreferredHeight and properties to properly size the Label control on the form on which it is displayed. This example requires that an ImageList has been created and named imageList1 and that it has loaded two images. The example also requires that the code is within a form that has the System.Drawing namespace added to its code.
Available since 1.1