![]() |
| | #1 |
| Registered User Join Date: Dec 2007
Posts: 380
| Search for words and change their color What is the best/good way to do, if I want to change the color of the word "hello" to Ex: red. Is there any searchfunction that can select multiple words etc... I am trying to find a way to do this. one two three hello five hello hello |
| Coding is offline | |
| | #2 |
| Registered User Join Date: Jun 2003
Posts: 90
| I have a complete mind block on the actual code, but know the process... (!) Put all the richTextBox contents in to a string, replace search term in string with the word itself and the formatting needed. ie. (but not actually this! This example replaces the term wanted with a bolded word in html format) Code: public static void ReplaceText(string myTerm)
{
string myString = richTextBox1.Text;
myString.Replace(myTerm, "<b>"+myTerm+"<\b>");
richTextBox1.Text = myString;
}
Code: ReplaceText("hello");
__________________ He who asks is a fool for five minutes, but he who does not ask remains a fool forever. The fool wonders, the wise man asks. - Benjamin Disraeli There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz Last edited by DanFraser; 03-26-2008 at 07:24 AM. |
| DanFraser is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary Search Trees Part III | Prelude | A Brief History of Cprogramming.com | 16 | 10-02-2004 03:00 PM |
| adding a function to a program | trippedwire | C++ Programming | 9 | 09-30-2004 12:35 PM |
| Trying to find a way to change color | Vanished | C++ Programming | 2 | 11-24-2002 11:16 AM |
| trying to make change from the price of the item and the amount given. please help!!! | tobyman | C++ Programming | 2 | 09-04-2001 02:12 PM |
| is there a way to set a pixel or change font color? | Flikm | C++ Programming | 9 | 09-01-2001 01:24 PM |