Solved

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

Posted on 2014-03-05
3
171 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:murbro
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 300 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 200 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:murbro
ID: 39911803
Thank you both for the help
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…

828 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