Solved

RTF Question

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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