Question LinkLabel Question...

aaronking

Member
Joined
Mar 21, 2009
Messages
6
Programming Experience
Beginner
Hello,

I have a linklabel on a form (called LinkLabel1) and I want to remove the underline of the control.

I know you can change the font ect and it has a tickbox for underline..

However, I want to remove the underline during runtime (using code).

Anyone know how to remove it using code during runtime?

I am using vb.net 2008 and I creating a 'Smart Device' application for 'windows CE'

anyone know how to do this?

Thanks.
 
aaronking said:
I know you can change the font ect and it has a tickbox for underline..
That is not how the underline for LinkLabel control works. You set the LinkLabel.LinkBehavior Property (System.Windows.Forms), one of the values is LinkBehavior.NeverUnderline. Leave the Fonts Underline unchecked in all cases. Note: documentation doesn't list any control specific members for LinkLabel in CE, is that right? If so, see the reply below.
Hack said:
The underline property is Read-Only so it would have to be moved in design.
In case you wondered, you can create a new Font object (also based on existing) and set new styles with constructor, this one for example: Font Constructor (Font, FontStyle) (System.Drawing)
VB.NET:
Dim f As Font = Me.LinkLabel1.Font        
Me.LinkLabel1.Font = New Font(f, f.Style And Not FontStyle.Underline)
 
Dim f As Font = Me.LinkLabel1.Font
Me.LinkLabel1.Font = New Font(f, f.Style And Not FontStyle.Underline)

This does not work..

it has a blue underline under: New Font(f, f.Style And Not FontStyle.Underline)

and it says: Overload resolution failed becasue no accessible 'New' accepts this number of arguments.

I am creating this with vb.net 2008 and its for a smart device application for Windows CE.
 
Oh, I forgot to check that also, CE really puts the restraints on ya, huh? :) For CE these constructors are listed:
help said:
Font(FontFamily, Single, FontStyle)
Font(String, Single, FontStyle)
Font Constructor (System.Drawing) (in the Frameworks dropdown select only CE)

VB.NET:
New Font(f.FontFamily, f.Size, f.Style And Not FontStyle.Underline)
 
I have added the following code on the Form_Load:

VB.NET:
Dim f As Font = Me.LinkLabel1.Font
        Me.LinkLabel1.Font = New Font("arial", f.Size, f.Style And Not FontStyle.Underline)

but when I run the application on windows XP the underline is still there.

But if I run the application on CE its gone.

Is there a way of making the underline hidden on XP as well as CE?
 
In full framework the LinkBehavior property takes effect, which is why I adviced to not underline the Font property with this.
 
In full framework the LinkBehavior property takes effect, which is why I adviced to not underline the Font property with this.

I have added a linklabel to the form without changing any settings to the font. (still didn't work) so I changed the underline in the font and it still didn't work.

the underline is not there when running it on the Windows CE device, but as soon as i run the same application on XP the line is there.
 
{Be hAppy}

Dim MyLabel As New LinkLabel
MyLabel.Text = "I am not under lined"
MyLabel.LinkBehavior = LinkBehavior.NeverUnderline
Me.Controls.Add(MyLabel)
 
Back
Top