Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi everyone,
My form contains many controls with arial font. I've created a linklabel on it runtime. By default it sets to "Microsoft Sans Serif", i think. I've tried to customize the font for link label to arial but it's not changed.
Any help??


Note : I cant able to upload my form snap sorry.
Posted
Updated 1-Apr-14 0:50am
v2

After you add your Control to your Form it inherits the Font from your Form (or the Container you use)

So i guess your Forms Font is not set, so it uses "Microsoft Sans Serif; 8,25pt" as default value.
and that gets inherited to your LinkLabel.

You can set your Font with
VB
yourLinkLabel.Font = New Font("Arial", 15)

AFTER it was added to a Container!
 
Share this answer
 
Comments
Vml_Newbie 1-Apr-14 6:45am    
I've tried to customize the font to "Arial" already using the same code u mentioned. But not working.
Sorry, Actually linklabel shows text in "Times New Roman" I think.
F. Xaver 1-Apr-14 7:47am    
That works fine for me.

you may try to add an Eventhandler for FontChanged on your linklabel, to see how often it changes..
or post some of your Code, can't say much without it
I'll check with event handler. And my code is.

VB
Friend WithEvents events_label As System.Windows.Forms.LinkLabel 
Private Sub treeUcompany_AfterSelect(ByVal sender As Object, ByVal e As TreeViewEventArgs) Handles treeUcompany.AfterSelect 
Me.events_label = New Windows.Forms.LinkLabel 
With events_label 
.Text = "Events: " & event_link 
.Location = New Point(31, 55) 
.LinkArea = New LinkArea(18, Len(events_label.Text)) 
.AutoSize = True 
.Font = New Font("Arial", 10) 
.Visible = True 
End With 
Me.pnlUCompanyDetails.Controls.Add(events_label)
End sub
 
Share this answer
 
v2
Comments
F. Xaver 1-Apr-14 8:34am    
is events_label somewhere added to Me.Controls?

i testet it like this
.Visible = True
End With
Me.Controls.Add(Me.events_label)

and it worked fine, displaying the Text with Arial, 10.
without "Me.Controls.Add(Me.events_label)" the lable isn't displayed at all.
Vml_Newbie 1-Apr-14 9:23am    
Ya you are correct Xaver. Just updated my coding in posting.
And i nowhere used events_label other than mentioned coding part. Do you got arial font for link label??
Let me try it one more time.
Vml_Newbie 1-Apr-14 10:29am    
Showing same result.
Event handler shows it's in arial font. But actuall output is in "Microsoft Sans Serif"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900