Page 51 - Open Soource Technologies 304.indd
P. 51
Unit 3: Understanding Controls and Control Events
Figure 3.9: LinkLabel.
3.4.3.1 LinkLabel Event
The default event of LinkLabel is the LinkClicked event which looks like this in code:
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)_
Handles LinkLabel1.LinkClicked
End Sub
3.4.3.2 Working with LinkLabel
Drag a LinkLabel (LinkLabel1) onto the form. When we click this LinkLabel it will take us to
"www.startvbdotnet.com". The code for that looks like this:
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal_
e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)_
Handles LinkLabel1.LinkClicked
System.Diagnostics.Process.Start("www.startvbdotnet.com")
'using the start method of system.diagnostics.process class
'process class gives access to local and remote processes
End Sub
3.4.3.3 Creating a LinkLabel in Code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
Dim LinkLabel1 As New LinkLabel()
LOVELY PROFESSIONAL UNIVERSITY 45