Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing font properties in TextBox.Text in VB.Net

Status
Not open for further replies.

KisiOne

Programmer
Sep 6, 2003
6
AU
I have a requirement to display a list of candidates in an election and make the winner's name red. I would like to use a multiline textbox to do this but don't know if I can change the font properties for part of the text only. If it is not possible to do, any suggestions on what other control I could use?
PK
 
The font properties for a text box apply to all text within it.

Use the RichTextBox control, which allows formatting of sections of text.
 
I can see how your suggestion helps a user to select and change font colour using a dialog but still don't see how I can set the font colour in a program.
 
Have a read of the help for RichTextBox - you can programatically change the font style of a text selection within the RichTextBox. This would allow you to change a specific line by programatically searching for and selecting the required text (in your case the winning candidates name) and applying a font colour of red.
 
Hi
to change the Font of the textbox at run-time you can
Dim objFont as font
objFont = New Font("Verdana", 8.25)
textbox1.font = objFont
As far as your question is yes go for Rich-Text Box and you can have more power than ordinary text-box
Regards
Nouman
 
Where can I get a list of the possible fonts (e.g. Verdana, etc..)

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top