Label control is used to display Text on the Form. Main property of the label control is the text property which is used to set the text in the label.

How to use Label Control

Drag and drop Label control from toolbox on the window Form.

Label Control in C#.Net

Display Text in Label. 

         private void Form8_Load(object sender, EventArgs e)
        {
            // display text in Label
            label1.Text = "Hello";
        }

Text will display in Label when Application run.

Label Control in C#.Net

Label Properties:

Text:   The text that appears on the Label control.

Enabled:  If this property is set to false, the Label appears grayed out.

 private void Form8_Load(object sender, EventArgs e)
        {
            //disable Label
            label1.Enabled = false;
        }


Label Control in C#.Net

BackColor:   Set the background color of Label control.

 private void Form8_Load(object sender, EventArgs e)
        {
            //change Label BackColor
            label1.BackColor = Color.CadetBlue;
        }

Output

Label Control in C#.Net

 ForeColor:  Set the ForeColor of Label control.

 private void Form8_Load(object sender, EventArgs e)
        {
            // change ForeColor of Label's text
            label1.ForeColor = Color.Red;
        }

Output

Label Control in C#.Net

  Modified On Mar-22-2018 07:15:14 AM

Leave Comment