Page 50 - Open Soource Technologies 304.indd
P. 50
Event Driven Programming
The TextBox is one of the handiest and most popular controls in a Windows
application. It’s a common approach to getting free-form input from the user.
You can manipulate a TextBox control’s contents and detect changes the user
makes to the TextBox through several Properties.
3.4.2 Label
Labels are those controls that are used to display text in other parts of the application. They are
based on the Control class.
Notable property of the label control is the text property which is used to set the text for the
label.
3.4.2.1 Label Event
The default event of Label is the Click event which looks like this in code:
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs)_
Handles Label1.Click
End Sub
3.4.2.2 Creating a Label in Code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load Dim Label1 As New Label()
Label1.Text = "Label"
Label1.Location = New Point(135, 70)
Label1.Size = New Size(30, 30)
Me.Controls.Add(Label1)
End Sub
3.4.3 LinkLabel
LinkLabel is similar to a Label but they display a hyperlink. Even multiple hyperlinks can be
specified in the text of the control and eachhyperlink can perform a different task within the
application. They are based on the Label class which is based on the Control class.
Notable properties of the LinkLabel control are the ActiveLinkColor, LinkColor and LinkVisited
which are used to set the link color.
44 LOVELY PROFESSIONAL UNIVERSITY