Solved

RTF Question

Posted on 2003-11-04
1
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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