Changing font of TextBox makes text invisable

gjconely

New member
Joined
Aug 7, 2006
Messages
2
Programming Experience
Beginner
I am working on an application that loads settings from a stored config file. When I load these settings, which contain a font and color, and then assign it to the "preview" Label, the Label no longer shows text. I even have it so that you can change this text, and after doing so, it still does not show any text. Here is the code that I am using to set the font and text color from the file.

myFont = New Font(strfontName, intfontSize, style:=strfontStyle)
txtPreview.Font = myFont
txtPreview.ForeColor = clrfontColor
txtPreview.BackColor = picBackColor.BackColor
txtPreview.Refresh()


txtPreview is a regular
Label. It has the text value of 'Sample Text'.

The 'strfontName' is a string value that holds the name of the font loaded from the file.

The 'intfontSize' is also loaded from the file and is an integer value.

The 'strFontStyle' is an integer value that is also loaded from file.

When I step through the application, everything looks good, but the
Label just stops working.

Any ideas?
 
Last edited by a moderator:
what are the values of "strfontName", "intfontSize" and "strfontStyle" when the label's text dissappears?

also if a control's name has the prefix "txt" then it's a textbox, you're using a label with a prefix of "txt" which is incorrect, the prefix for a label is "lbl" so your "txtPreview" name should be "lblPreview" in this case

also the new naming standard is to name the control with a name first then put the name of the control afterwards:
instead of "lblPreview" it would be named "previewLabel"

just an fyi
 
put a breakpoint on the txtPreview.Refresh() line

when it hits, type the following into the immediate window, and paste the results back to us:

?txtPreview.Font
?txtPreview.ForeColor
?txtPreview.BackColor
?txtPreview.Text
 
Back
Top