VB.net - Label Control


Microsoft Visual Studio .NET controls are the graphical tools you use to build the user interface of a VB.Net program. Labels are one of the most frequently used Visual Basic control.

A Label control lets you place descriptive text , where the text does not need to be changed by the user. The Label class is defined in the System.Windows.Forms namespace.

vb.net-label.jpg

Add a Label control to the form. Click Label in the Toolbox and drag it over the forms Designer and drop it in the desired location.

If you want to change the display text of the Label, you have to set a new text to the Text property of Label.

 

Label1.Text = "This is my first Label"

 

 

You can load Image in Label control , if you want to load an Image in the Lable control you can code like this

 

 

Label1.Image = Image.FromFile("C:\testimage.jpg")

 

 

The following source code shows how to set some properties of the Label through coding.

 

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = "This is my first Label"
        Label1.BorderStyle = BorderStyle.FixedSingle
        Label1.TextAlign = ContentAlignment.MiddleCenter
    End Sub
End Class
Next Post Previous Post
No Comment
Add Comment
comment url