Windows Develop Bookmark and Share   
 index > Windows Forms General > Change color without Selecting Text in RichTextBox
 

Change color without Selecting Text in RichTextBox


That is my question...

How can i change in C# the color (and font properties if possible) without selecting the text. I hve a RichTextBox and i want that while you are writing if the program recognize a Special word, it change the color. I do this by this way:

Code Snippet

//ini = start index of the word

//fin = end index of the word

if (word == "special_word")
{
RichTextBox1.Select(ini, fin);
RichTextBox1.SelectionColor = Color.DarkBlue;
RichTextBox1.SelectionFont = new Font("Tahoma", 8, FontStyle.Bold);
RichTextBox1.Select(RichTextBox1.Text.Length, RichTextBox1.Text.Length);
}


And it works, but... When you are typing you can see the text SELECTING and DISELECTING and it is very ugly xDDD

So, are there any way to change Text properties without selecting the text ??
AnHeLL  Thursday, May 10, 2007 11:29 AM

Hi,please check these artilces from MSDN

RichTextBox.SelectionBackColor Property

RichTextBox.SelectionColor Property

Hope it helps.

Best Regards.

Gavin Jin - MSFT  Monday, May 14, 2007 7:24 AM
Well, at least tell me how hide the background color of the selection or how to put it in white.

I know that it can't be difficult but i don't find any way to do this...

Thanks a lot.

AnHeLL  Thursday, May 10, 2007 3:35 PM

Hi,please check these artilces from MSDN

RichTextBox.SelectionBackColor Property

RichTextBox.SelectionColor Property

Hope it helps.

Best Regards.

Gavin Jin - MSFT  Monday, May 14, 2007 7:24 AM

You can use google to search for other answers

Custom Search

More Threads

• "A first chance excep typ 'System.InvalidOperationException' occurred in System.Windows.Forms.dll COM" problem (THREADS)?
• Installing a simple .NET application that uses MS Access
• Expansion of TreeView node on mouse stay time..
• Program efficiency: consolidating multiple instances of OpenFileDialog (VB2008)
• print cartidge missing message when I print
• Child in dll
• Create SQL Logins Using C#.net
• .NET Remoting Security Permission
• syntax help for select case
• How to get the Hardware Acceleration Status??