articles

Home / DeveloperSection / Articles / A Label Control in VB.Net

A Label Control in VB.Net

A Label Control in VB.Net

Pushpendra Singh 17714 14-Dec-2010

A Label Control in VB.Net

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

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

A Label Control in VB.Net

Display Text in Label.

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'display text in Label
        Label1.Text = "Hello"
 End Sub

The text will display in Label when Form gets executed.

A Label Control in VB.Net

The main event of Label is the Click event.

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        'MessageBox will show message
        MessageBox.Show("How are you")
End Sub

A Label Control in VB.Net

When you click on the Text Hello is written in Label then click event will fire and the message box will display the message.

A Label Control in VB.Net

Label Control Properties

ForeColor:

The ForeColor of Label can be changed through the ForeColor Property of Label.

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'change Label ForeColor
        Label1.ForeColor = Color.Red
End Sub

A Label Control in VB.Net


Updated 28-Mar-2020

Leave Comment

Comments

Liked By