Get LinkData from LinkLabel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinkLabelLocalRemote
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"LinkLabel1
"
Me.LinkLabel1.Location = New System.Drawing.Point(32, 80)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(224, 16)
Me.LinkLabel1.TabIndex = 0
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "Get more information locally or on the web."
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.LinkLabel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LinkLabel1.Links.Add(21, 7, "locally")
LinkLabel1.Links.Add(39, 3, "web")
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LinkLabel1.Links(LinkLabel1.Links.IndexOf(e.Link)).Visited = True
If (e.Link.LinkData.ToString() = "locally") Then
Dim InfoWindow As New Form2
InfoWindow.Show()
Else
System.Diagnostics.Process.Start("www.vbex.ru")
End If
End Sub
End Class
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"Label1
"
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(176, 48)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Form 2"
"
"Form2
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Name = "Form2"
Me.Text = "Form2"
Me.ResumeLayout(False)
End Sub
#End Region
End Class
Link Add
imports System
imports System.Drawing
imports System.Windows.Forms
public class LinkLabelsLinkAdd : inherits Form
dim lnkMsft as LinkLabel
dim lnkLA as LinkLabel
public sub New()
Size = new Size(300,250)
lnkLA = new LinkLabel()
lnkLA.Parent = me
lnkLA.Text = "Liberty Associates"
lnkLA.Location = new Point(0,25)
lnkLA.AutoSize = true
lnkLA.BorderStyle = BorderStyle.None
lnkLA.Links.Add(0,17,"www.LibertyAssociates.ru")
AddHandler lnkLA.LinkClicked, AddressOf lnkMsft_LinkClicked
end sub
public shared sub Main()
Application.Run(new LinkLabelsLinkAdd())
end sub
private sub lnkMsft_LinkClicked(ByVal sender as object, ByVal e as LinkLabelLinkClickedEventArgs)
lnkMsft.Links(lnkMsft.Links.IndexOf(e.Link)).Visited = true
System.Diagnostics.Process.Start(lnkMsft.Text)
end sub
end class
LinkArea in LinkLabel
imports System
imports System.Drawing
imports System.Windows.Forms
public class LinkLabelsLinkArea : inherits Form
dim lnkMsft as LinkLabel
dim lnkLA as LinkLabel
public sub New()
Size = new Size(300,250)
" use Text property & LinkArea
lnkMsft = new LinkLabel()
lnkMsft.Parent = me
lnkMsft.Text = "www.microsoft.ru"
lnkMsft.Location = new Point(0,0)
lnkMsft.AutoSize = true
lnkMsft.BorderStyle = BorderStyle.None
lnkMsft.LinkArea = new LinkArea(4,9)
AddHandler lnkMsft.LinkClicked, AddressOf lnkMsft_LinkClicked
end sub
public shared sub Main()
Application.Run(new LinkLabelsLinkArea())
end sub
private sub lnkMsft_LinkClicked(ByVal sender as object, ByVal e as LinkLabelLinkClickedEventArgs)
lnkMsft.Links(lnkMsft.Links.IndexOf(e.Link)).Visited = true
System.Diagnostics.Process.Start(lnkMsft.Text)
end sub
end class
LinkLabel: LinkArea, LinkColor, VisitedLinkColor, ActiveLinkColor
Imports System.Windows.Forms
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
public class LinkLabelLinkData
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LinkLabel1.Text = "Home Page is www.microsoft.ru"
LinkLabel1.Links.Add(13, 28, "http://www.microsoft.ru")
LinkLabel1.LinkArea = New LinkArea(13, 28)
LinkLabel1.LinkColor = Color.Red
LinkLabel1.VisitedLinkColor = Color.Aqua
LinkLabel1.ActiveLinkColor = Color.Pink
LinkLabel1.Links(0).LinkData = "Register"
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Label1.Text = LinkLabel1.Text
End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
"Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
Me.Button1 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"LinkLabel1
"
Me.LinkLabel1.AutoSize = True
Me.LinkLabel1.Location = New System.Drawing.Point(182, 51)
Me.LinkLabel1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(87, 15)
Me.LinkLabel1.TabIndex = 0
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "LinkLabel1"
"
"Button1
"
Me.Button1.Location = New System.Drawing.Point(185, 181)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(139, 28)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
"
"Label1
"
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(64, 51)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(55, 15)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1"
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(547, 250)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.LinkLabel1)
Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
End Class
LinkLabel local action
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class LinkLabelLocalRemote
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.LinkLabel1 = New System.Windows.Forms.LinkLabel
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"LinkLabel1
"
Me.LinkLabel1.Location = New System.Drawing.Point(32, 80)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(224, 16)
Me.LinkLabel1.TabIndex = 0
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "Get more information locally or on the web."
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.LinkLabel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LinkLabel1.Links.Add(21, 7, "locally")
LinkLabel1.Links.Add(39, 3, "web")
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
LinkLabel1.Links(LinkLabel1.Links.IndexOf(e.Link)).Visited = True
If (e.Link.LinkData.ToString() = "locally") Then
Dim InfoWindow As New Form2
InfoWindow.Show()
Else
System.Diagnostics.Process.Start("www.vbex.ru")
End If
End Sub
End Class
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.IContainer
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
"
"Label1
"
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(0, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(176, 48)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Form 2"
"
"Form2
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label1)
Me.Name = "Form2"
Me.Text = "Form2"
Me.ResumeLayout(False)
End Sub
#End Region
End Class
Load Browser
Imports System.Windows.Forms
public class LinkLabelAction
public Shared Sub Main
Application.Run(New FrmLinkLabel)
End Sub
End class
Public Class FrmLinkLabel
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
" linklabels to C: drive, www.deitel.ru and Notepad
Friend WithEvents lnklblCDrive As LinkLabel
Friend WithEvents lnklblDeitel As LinkLabel
Friend WithEvents lnklblNotepad As LinkLabel
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lnklblNotepad = New LinkLabel()
Me.lnklblCDrive = New LinkLabel()
Me.lnklblDeitel = New LinkLabel()
Me.SuspendLayout()
"
"lnklblNotepad
"
Me.lnklblNotepad.Location = New System.Drawing.Point(72, 112)
Me.lnklblNotepad.Name = "lnklblNotepad"
Me.lnklblNotepad.Size = New System.Drawing.Size(128, 23)
Me.lnklblNotepad.TabIndex = 2
Me.lnklblNotepad.TabStop = True
Me.lnklblNotepad.Text = "Click to run Notepad"
"
"lnklblCDrive
"
Me.lnklblCDrive.Location = New System.Drawing.Point(72, 16)
Me.lnklblCDrive.Name = "lnklblCDrive"
Me.lnklblCDrive.TabIndex = 0
Me.lnklblCDrive.TabStop = True
Me.lnklblCDrive.Text = "Click to browse C:\"
"
"lnklblDeitel
"
Me.lnklblDeitel.Location = New System.Drawing.Point(72, 64)
Me.lnklblDeitel.Name = "lnklblDeitel"
Me.lnklblDeitel.Size = New System.Drawing.Size(152, 23)
Me.lnklblDeitel.TabIndex = 1
Me.lnklblDeitel.TabStop = True
Me.lnklblDeitel.Text = "Click to visit www.vbex.ru"
"
"FrmLinkLabel
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(264, 149)
Me.Controls.AddRange(New Control() {Me.lnklblNotepad, Me.lnklblDeitel, Me.lnklblCDrive})
Me.Name = "FrmLinkLabel"
Me.Text = "LinkLabelTest"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub lnklblCDrive_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblCDrive.LinkClicked
lnklblCDrive.LinkVisited = True
System.Diagnostics.Process.Start("C:\")
End Sub
Private Sub lnklblDeitel_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblDeitel.LinkClicked
lnklblDeitel.LinkVisited = True
System.Diagnostics.Process.Start("IExplore", "http://www.vbex.ru")
End Sub " lnklblDeitel
" run application Notepad
Private Sub lnklblNotepad_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblNotepad.LinkClicked
lnklblNotepad.LinkVisited = True
System.Diagnostics.Process.Start("notepad")
End Sub
End Class
Load File Explore
Imports System.Windows.Forms
public class LinkLabelAction
public Shared Sub Main
Application.Run(New FrmLinkLabel)
End Sub
End class
Public Class FrmLinkLabel
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
" linklabels to C: drive, www.deitel.ru and Notepad
Friend WithEvents lnklblCDrive As LinkLabel
Friend WithEvents lnklblDeitel As LinkLabel
Friend WithEvents lnklblNotepad As LinkLabel
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lnklblNotepad = New LinkLabel()
Me.lnklblCDrive = New LinkLabel()
Me.lnklblDeitel = New LinkLabel()
Me.SuspendLayout()
"
"lnklblNotepad
"
Me.lnklblNotepad.Location = New System.Drawing.Point(72, 112)
Me.lnklblNotepad.Name = "lnklblNotepad"
Me.lnklblNotepad.Size = New System.Drawing.Size(128, 23)
Me.lnklblNotepad.TabIndex = 2
Me.lnklblNotepad.TabStop = True
Me.lnklblNotepad.Text = "Click to run Notepad"
"
"lnklblCDrive
"
Me.lnklblCDrive.Location = New System.Drawing.Point(72, 16)
Me.lnklblCDrive.Name = "lnklblCDrive"
Me.lnklblCDrive.TabIndex = 0
Me.lnklblCDrive.TabStop = True
Me.lnklblCDrive.Text = "Click to browse C:\"
"
"lnklblDeitel
"
Me.lnklblDeitel.Location = New System.Drawing.Point(72, 64)
Me.lnklblDeitel.Name = "lnklblDeitel"
Me.lnklblDeitel.Size = New System.Drawing.Size(152, 23)
Me.lnklblDeitel.TabIndex = 1
Me.lnklblDeitel.TabStop = True
Me.lnklblDeitel.Text = "Click to visit www.vbex.ru"
"
"FrmLinkLabel
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(264, 149)
Me.Controls.AddRange(New Control() {Me.lnklblNotepad, Me.lnklblDeitel, Me.lnklblCDrive})
Me.Name = "FrmLinkLabel"
Me.Text = "LinkLabelTest"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub lnklblCDrive_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblCDrive.LinkClicked
lnklblCDrive.LinkVisited = True
System.Diagnostics.Process.Start("C:\")
End Sub
Private Sub lnklblDeitel_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblDeitel.LinkClicked
lnklblDeitel.LinkVisited = True
System.Diagnostics.Process.Start("IExplore", "http://www.vbex.ru")
End Sub " lnklblDeitel
" run application Notepad
Private Sub lnklblNotepad_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblNotepad.LinkClicked
lnklblNotepad.LinkVisited = True
System.Diagnostics.Process.Start("notepad")
End Sub
End Class
Load Window Application
Imports System.Windows.Forms
public class LinkLabelAction
public Shared Sub Main
Application.Run(New FrmLinkLabel)
End Sub
End class
Public Class FrmLinkLabel
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
" linklabels to C: drive, www.deitel.ru and Notepad
Friend WithEvents lnklblCDrive As LinkLabel
Friend WithEvents lnklblDeitel As LinkLabel
Friend WithEvents lnklblNotepad As LinkLabel
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lnklblNotepad = New LinkLabel()
Me.lnklblCDrive = New LinkLabel()
Me.lnklblDeitel = New LinkLabel()
Me.SuspendLayout()
"
"lnklblNotepad
"
Me.lnklblNotepad.Location = New System.Drawing.Point(72, 112)
Me.lnklblNotepad.Name = "lnklblNotepad"
Me.lnklblNotepad.Size = New System.Drawing.Size(128, 23)
Me.lnklblNotepad.TabIndex = 2
Me.lnklblNotepad.TabStop = True
Me.lnklblNotepad.Text = "Click to run Notepad"
"
"lnklblCDrive
"
Me.lnklblCDrive.Location = New System.Drawing.Point(72, 16)
Me.lnklblCDrive.Name = "lnklblCDrive"
Me.lnklblCDrive.TabIndex = 0
Me.lnklblCDrive.TabStop = True
Me.lnklblCDrive.Text = "Click to browse C:\"
"
"lnklblDeitel
"
Me.lnklblDeitel.Location = New System.Drawing.Point(72, 64)
Me.lnklblDeitel.Name = "lnklblDeitel"
Me.lnklblDeitel.Size = New System.Drawing.Size(152, 23)
Me.lnklblDeitel.TabIndex = 1
Me.lnklblDeitel.TabStop = True
Me.lnklblDeitel.Text = "Click to visit www.vbex.ru"
"
"FrmLinkLabel
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(264, 149)
Me.Controls.AddRange(New Control() {Me.lnklblNotepad, Me.lnklblDeitel, Me.lnklblCDrive})
Me.Name = "FrmLinkLabel"
Me.Text = "LinkLabelTest"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub lnklblCDrive_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblCDrive.LinkClicked
lnklblCDrive.LinkVisited = True
System.Diagnostics.Process.Start("C:\")
End Sub
Private Sub lnklblDeitel_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblDeitel.LinkClicked
lnklblDeitel.LinkVisited = True
System.Diagnostics.Process.Start("IExplore", "http://www.vbex.ru")
End Sub " lnklblDeitel
" run application Notepad
Private Sub lnklblNotepad_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblNotepad.LinkClicked
lnklblNotepad.LinkVisited = True
System.Diagnostics.Process.Start("notepad")
End Sub
End Class
Multiple links and generic handler
imports System
imports System.Drawing
imports System.Windows.Forms
public class LinkLabelsGeneric : inherits Form
dim lnkMsft as LinkLabel
dim lnkLA as LinkLabel
public sub New()
Size = new Size(300,250)
" multiple links & generic handler
dim lnkMulti as LinkLabel = new LinkLabel()
lnkMulti.Parent = me
lnkMulti.Text = "AAAA AAAAA AA AAAAAAA"
lnkMulti.Location = new Point(0,75)
lnkMulti.AutoSize = true
lnkMulti.BorderStyle = BorderStyle.None
lnkMulti.LinkBehavior = LinkBehavior.HoverUnderline
lnkMulti.Links.Add(0,4,"www.vbex.ru")
lnkMulti.Links.Add(6,5,"www.vbex.ru")
lnkMulti.Links.Add(13,2, "www.vbex.ru")
lnkMulti.Links.Add(17,7,"www.vbex.ru")
AddHandler lnkMulti.LinkClicked, AddressOf lnkGeneric_LinkClicked
end sub
public shared sub Main()
Application.Run(new LinkLabelsGeneric())
end sub
private sub lnkGeneric_LinkClicked(ByVal sender as object, _
ByVal e as LinkLabelLinkClickedEventArgs)
dim lnk as LinkLabel = new LinkLabel()
lnk = CType(sender, LinkLabel)
lnk.Links(lnk.Links.IndexOf(e.Link)).Visited = true
Console.WriteLine(e.Link.LinkData.ToString())
"System.Diagnostics.Process.Start(e.Link.LinkData.ToString())
end sub
end class
Set Label Border style
imports System
imports System.Drawing
imports System.Windows.Forms
public class Timers : inherits Form
dim lblTime as Label
public sub New()
Size = new Size(300,100)
lblTime = new Label()
lblTime.Parent = me
lblTime.Size = new Size(200, 25)
lblTime.Location = new Point(20,20)
lblTime.BorderStyle = BorderStyle.FixedSingle
lblTime.TextAlign = ContentAlignment.MiddleCenter
dim t as new Timer()
t.Interval = 100
t.Start()
AddHandler t.Tick, AddressOf t_Tick
end sub
public shared sub Main()
Application.Run(new Timers())
end sub
private sub t_Tick(ByVal sender as object,ByVal e as EventArgs)
lblTime.Text = DateTime.Now.ToString("dddd, MMMM d, yyyy h:mm:ss tt")
end sub
end class
Set LinkLabel ImageList
imports System
imports System.Drawing
imports System.Windows.Forms
public class LinkLabelImageList : inherits Form
dim imgList as ImageList = new ImageList()
dim lbl as Label
dim lnk as LinkLabel
dim btn as Button
dim nmbrUpDown as NumericUpDown
public sub New()
Size = new Size(300,300)
dim img as Image
dim i as integer
dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"}
for i = 0 to arFiles.Length - 1
img = Image.FromFile(arFiles(i))
imgList.Images.Add(img)
next
lnk = new LinkLabel()
lnk.Parent = me
lnk.Text = "LinkLabel"
lnk.Size = new Size(200,20)
lnk.Location = new Point(0, 0)
lnk.ImageList = imgList
lnk.ImageIndex = 0
lnk.ImageAlign = ContentAlignment.MiddleRight
" Create numeric updown to select the image
nmbrUpDown = new NumericUpDown()
nmbrUpDown.Parent = me
nmbrUpDown.Location = new Point(0, 60)
nmbrUpDown.Value = 0
nmbrUpDown.Minimum = 0
nmbrUpDown.Maximum = imgList.Images.Count - 1
nmbrUpDown.Width = 50
nmbrUpDown.ReadOnly = true
AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged
end sub
public shared sub Main()
Application.Run(new LinkLabelImageList())
end sub
private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs)
dim n as NumericUpDown = CType(sender, NumericUpDown)
lnk.ImageIndex = CType(n.Value, Integer)
end sub
end class
Using LinkLabels to create hyperlinks
Imports System.Windows.Forms
public class LinkLabelAction
public Shared Sub Main
Application.Run(New FrmLinkLabel)
End Sub
End class
Public Class FrmLinkLabel
Inherits Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
" linklabels to C: drive, www.deitel.ru and Notepad
Friend WithEvents lnklblCDrive As LinkLabel
Friend WithEvents lnklblDeitel As LinkLabel
Friend WithEvents lnklblNotepad As LinkLabel
"Required by the Windows Form Designer
Private components As System.ruponentModel.Container
"NOTE: The following procedure is required by the Windows Form Designer
"It can be modified using the Windows Form Designer.
"Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.lnklblNotepad = New LinkLabel()
Me.lnklblCDrive = New LinkLabel()
Me.lnklblDeitel = New LinkLabel()
Me.SuspendLayout()
"
"lnklblNotepad
"
Me.lnklblNotepad.Location = New System.Drawing.Point(72, 112)
Me.lnklblNotepad.Name = "lnklblNotepad"
Me.lnklblNotepad.Size = New System.Drawing.Size(128, 23)
Me.lnklblNotepad.TabIndex = 2
Me.lnklblNotepad.TabStop = True
Me.lnklblNotepad.Text = "Click to run Notepad"
"
"lnklblCDrive
"
Me.lnklblCDrive.Location = New System.Drawing.Point(72, 16)
Me.lnklblCDrive.Name = "lnklblCDrive"
Me.lnklblCDrive.TabIndex = 0
Me.lnklblCDrive.TabStop = True
Me.lnklblCDrive.Text = "Click to browse C:\"
"
"lnklblDeitel
"
Me.lnklblDeitel.Location = New System.Drawing.Point(72, 64)
Me.lnklblDeitel.Name = "lnklblDeitel"
Me.lnklblDeitel.Size = New System.Drawing.Size(152, 23)
Me.lnklblDeitel.TabIndex = 1
Me.lnklblDeitel.TabStop = True
Me.lnklblDeitel.Text = "Click to visit www.vbex.ru"
"
"FrmLinkLabel
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(264, 149)
Me.Controls.AddRange(New Control() {Me.lnklblNotepad, Me.lnklblDeitel, Me.lnklblCDrive})
Me.Name = "FrmLinkLabel"
Me.Text = "LinkLabelTest"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub lnklblCDrive_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblCDrive.LinkClicked
lnklblCDrive.LinkVisited = True
System.Diagnostics.Process.Start("C:\")
End Sub
Private Sub lnklblDeitel_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblDeitel.LinkClicked
lnklblDeitel.LinkVisited = True
System.Diagnostics.Process.Start("IExplore", "http://www.vbex.ru")
End Sub " lnklblDeitel
" run application Notepad
Private Sub lnklblNotepad_LinkClicked _
(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnklblNotepad.LinkClicked
lnklblNotepad.LinkVisited = True
System.Diagnostics.Process.Start("notepad")
End Sub
End Class