By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

How to change font size dynamically?

P: 3
I see this question has been brought up before but the thread was closed. I inherited a website where clients can submit transactions and on the same site we can approve them internally. To make the process easier I've been asked to highlight the Label fields where changes were made. I've also been asked to make the text Bold. The Labels are contained in a Form so the font is ReadOnly. The previous post said you could get around that by creating a new Font. I am still frustrated by Property 'Font' is 'ReadOnly'. Any advice would be appreciated.
Expand|Select|Wrap|Line Numbers
  1. Dim boldFont As New Font("Calibri", FontStyle.Bold)
  2. Dim lLabelFirstName As Label = _
  3. FormViewReviewEnrollment.FindControl("LabelFirstName")
  4. lLabelFirstName.BackColor = Color.Yellow
  5. lLabelFirstName.Font = boldFont
  6.  
Oct 21 '14 #1

✓ answered by iam_clint

Expand|Select|Wrap|Line Numbers
  1.         Dim lLabelFirstName As Label = DirectCast(FormView1.FindControl("ClubNameLbl"), Label)
  2.         lLabelFirstName.BackColor = Drawing.Color.Yellow
  3.         lLabelFirstName.Font.Bold = True
  4.  
I had absolutely no problems running this code from a button on an item in the formview.

Share this Question
Share on Google+
4 Replies


iam_clint
Expert 100+
P: 1,208
I believe you can set the individual properties. .font.bold=true. .font.size=13
Oct 22 '14 #2

P: 3
Not when it is containted in a <asp:FormView>. I keep getting errors saying that Font is readonly if I try to add code to update it in the VB
Oct 22 '14 #3

iam_clint
Expert 100+
P: 1,208
Expand|Select|Wrap|Line Numbers
  1.         Dim lLabelFirstName As Label = DirectCast(FormView1.FindControl("ClubNameLbl"), Label)
  2.         lLabelFirstName.BackColor = Drawing.Color.Yellow
  3.         lLabelFirstName.Font.Bold = True
  4.  
I had absolutely no problems running this code from a button on an item in the formview.
Oct 22 '14 #4

P: 3
I don't know what I was doing wrong but I must not have been doing something correctly because it is working now. Thank you so much.
Oct 22 '14 #5

Post your reply

Sign in to post your reply or Sign up for a free account.