Solved

RTF Question

Posted on 2003-11-04
1
191 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

11 Experts available now in Live!

Get 1:1 Help Now