Different color texts

Chris Ara
04-06-2006, 05:26 PM
Hey I am making a programm that uses a multi line text box and want the text to be in different colors. Is there any way I can get the text box draw one word with one color and another word with a different color. That way different word groups in the same text box appear in different colors. Thanks for any help.

GForce
04-07-2006, 08:47 AM
The RichTextBox Control gives you control over Fonts, Colors, Weights, Size, etc.

Chris Ara
04-07-2006, 09:49 AM
I think you misunderstood my question. I want to have one textbox with different color words in it. I trying to make a textbox that highlights only certian characters.

GForce
04-07-2006, 09:52 AM
I think you misunderstood my question. I want to have one textbox with different color words in it. I trying to make a textbox that highlights only certian characters.
Text box is the wrong control, use a RichTextBox!

JNewt
04-07-2006, 11:20 AM
Check this out: http://www.startvbdotnet.com/controls/rtb.aspx

Chris Ara
04-07-2006, 04:50 PM
Where can I go to learn more about the rich text box control. The documentation with visual studio is not very helpful on the color changing front.

Chris Ara
04-08-2006, 06:14 PM
O.k. I looked throught all these sites and I still cannot find what I am looking for. I just need a rich text box that highlights only certain words as you type. Can I format it to do that something? thanks for any help.

GForce
04-10-2006, 01:29 PM
The solution you are looking for is RichTextBox Control (Try using Help on RichTextBox Class) and a RegularExpression to find the occurances of a sequence of characters. You will have to programmatically search for those sequence(s) of characters you wish to format differently.

The following lines change "Selected Text" to Verdana 12pt Bold Red:

richTextBox1.SelectionFont = New Font("Verdana", 12, FontStyle.Bold)
richTextBox1.SelectionColor = Color.Red

A good example of the RichTextBox Control is WordPad. In fact there should be a demonstration of using the RichTextBox to make a WordPad App with previous versions of VB that would be easily upgraded.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum