Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net Property 'Name' is 'ReadOnly'.

Posted on 2014-03-05
3
Medium Priority
?
176 Views
Last Modified: 2014-03-06
Hi
I have a font name stored as text in a database.
I am trying to use this string to set the font name of a text box in
the line of code below but am getting the error: "Property 'Name' is 'ReadOnly'."

     Dim ChartTitleFontName As String = arrSplit3(1)
     Me.txtChartTitle.Font.Name = ChartTitleFontName
0
Comment
Question by:Murray Brown
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1200 total points
ID: 39907138
You have to create an object of font

Me.txtChartTitle.Font = New Font(ChartTitleFontName, 12)
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 800 total points
ID: 39907285
I would go a step further and would not set a hard coded size. This way, if you ever change the FontSize of the TextBox, you code will follow the change:

New Font(ChartTitleFontName, Me.txtChartTitle.Font.Size)

You might want to do that with other characteristics as well (Bold, Italic...)
0
 

Author Closing Comment

by:Murray Brown
ID: 39911803
Thank you both for the help
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question