Problems Dynamically creating a LinkLabel

J

Joshua Ellul

Hi There,

I'm trying to create a link label dynmically. The problems I'm having is
the following:
1. The LinkLabel is created without the underline
2. The click event is not being raised...

Here's my code:

Dim newLink As New LinkLabel()
With newLink
pnlTitle.Controls.AddRange(New System.Windows.Forms.Control() {newLink})
..Left = 100
..Top = 100
..AutoSize = True
..LinkBehavior = LinkBehavior.AlwaysUnderline
..ActiveLinkColor = System.Drawing.Color.Red
..Font = FontConv.ConvertFromString("Verdana, 14.25pt")
..Text = Desc
AddHandler .Click, AddressOf Me.Links_LinkClicked
AddHandler .MouseMove, AddressOf Me.Links_MM
End With

and the subs:
Private Sub Links_LinkClicked(ByVal sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show("Link Clicked")
End Sub

Any Ideas?

Josh
 
H

Herfried K. Wagner [MVP]

* "Joshua Ellul said:
I'm trying to create a link label dynmically. The problems I'm having is
the following:
1. The LinkLabel is created without the underline
2. The click event is not being raised...

Here's my code:

Dim newLink As New LinkLabel()
With newLink
pnlTitle.Controls.AddRange(New System.Windows.Forms.Control() {newLink})
.Left = 100
.Top = 100
.AutoSize = True
.LinkBehavior = LinkBehavior.AlwaysUnderline
.ActiveLinkColor = System.Drawing.Color.Red
.Font = FontConv.ConvertFromString("Verdana, 14.25pt")
.Text = Desc
AddHandler .Click, AddressOf Me.Links_LinkClicked
AddHandler .MouseMove, AddressOf Me.Links_MM
End With

and the subs:
Private Sub Links_LinkClicked(ByVal sender As Object, ByVal e As
System.EventArgs)
MessageBox.Show("Link Clicked")
End Sub

Any Ideas?

I am not able to repro problem 2 with the code listed above. I use .NET 1.0,
Windows XP Professional.

For your 1st gestion:

\\\
..Font = New Font(Me.Font, FontStyle.Underline)
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top