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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to populated text box with two different fonts 1

Status
Not open for further replies.

KellyStee

Technical User
Jul 30, 2001
106
0
0
US
I have a text box and with the click of a button I need to have inserted into the text box "Line to" and then the infinity symbol, which is a character in the symbol font.

Font:="Symbol",
CharacterNumber:=-3931,
Unicode:= True

The problem is that I need the "Line to" wording to be in Arial font or some other basic font like that. So, I have two fonts in the same textbox, which isn't do-able.

Any ideas?
Please help!

Thanks!
Kelly
 
Use RichTextBox instead of a regular TextBox. You can use the .SelStart and .SelLength properties to select an section of text and then use the .SelFontName to change the font. For example (where rtb is a RichTextBox control):
Code:
rtb.SelStart = 0
rtb.SelLength = 5
rtb.SelFontName = "Times New Roman"
rtb.SelStart = 7
rtb.SelLength = 5
rtb.SelFontName = "Symbol"
 
AdaHacker,
I have made a lot of progress with your help. Thanks so much for the suggestion. I do have a problem, though. The two different fonts (and colors) that I need to use in my RichTextBox vary depending on the character. So, for instance, if a "2" is displayed in the box, I need it to be in one font and one color and if a "5" is displayed, I need it to be in a different color. And I never know what order the characters are going to appear. So, based on your example, I can't always say that the second character in the box always needs to be a certain font and color. It depends on the character.

Any ideas?

Thanks again for your help!!
Kelly
 
in the keypress event of the rich text box check for the character and set the font type accordingly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top