Home > DeveloperSection > Beginner > Label Control in C#.Net

Label Control in C#.Net


C# C# 
Ratings:
0 Comment(s)
 9892  View(s)
Rate this:

Label Control in C#.Net

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


Don't want to miss updates? Please click the below button!

Follow MindStick