Solved

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

Posted on 2014-03-05
3
172 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

763 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