Solved

RTF Question

Posted on 2003-11-04
1
192 Views
Last Modified: 2010-04-16
I have a RichTextBox. When the user types in a certain word such as "hello" I want the font color of that word to chance to another color like blue. This is like syntax highlighting in Visual Studio .Net and other development enviroments. Ive tried to do this but cannot find an answer. Please help me.
0
Comment
Question by:GoRgOn
1 Comment
 
LVL 1

Accepted Solution

by:
rashmitodkar earned 50 total points
ID: 9700098
hi try with the following code

private void RTB_TextChanged(object sender, System.EventArgs e)
            {
                  for (int i=0;i<RTB.Text.Length;i++)
                  {
                        if (RTB.Text.IndexOf("hello",i)>=0)
                        {
                              RTB.Select(RTB.Text.IndexOf("hello",i),5);    
                              RTB.SelectionColor =Color.Blue;    
                              RTB.Select(RTB.Text.Length,0);
                              RTB.SelectionColor =Color.Black ;  
                              i=i+5;
                        }
                  }
                  
                  
            }
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 47
How to LOAD up a .NET Framework website with data? 2 39
Why Does This Page Not Show Up? 4 22
Host asp.net pages 5 25
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now