Open In App

Label in C#

In Windows Forms, Label control is used to display text on the form and it does not take part in user input or in mouse or keyboard events. The Label is a class and it is defined under System.Windows.Forms namespace. In windows form, you can create Label in two different ways:

1. Design-Time: It is the easiest method to create a Label control using the following steps:



2. Run-Time: It is a little bit trickier than the above method. In this method, you can set create your own Label control using the Label class. Steps to create a dynamic label:



Important Properties of the Label Control

Property Description
AutoSize This property is used to set a value indicating whether the Label control is automatically resized to display its entire contents.
BackColor This property is used to set the background color for the Label control.
BackgroundImage This property is used to set the background image for the Label control.
BorderStyle This property is used to set the border style for the Label control.
FlatStyle This property is used to set the flat style appearance of the label control.
Font This property is used to set the font of the text displayed by the Label control.
FontHeight This property is used to set the height of the font of the Label control.
ForeColor This property is used to set the foreground color of the Label control.
Height This property is used to set the height of the Label control.
Image This property is used to set the image that is displayed on a Label.
Location This property is used to set the coordinates of the upper-left corner of the Label control relative to the upper-left corner of its form.
Name This property is used to set the name of the Label control.
Padding This property is used to set padding within the Label control.
Size This property is used to set the height and width of the Label control.
Text This property is used to set the text associated with this Label control.
TextAlign This property is used to set the alignment of text in the label.
Visible This property is used to set a value indicating whether the control and all its child controls are displayed.
Width This property is used to set the width of the Label control.

Article Tags :
C#