Archived

This topic is now archived and is closed to further replies.

template

Best way to do syntax highlighting

Recommended Posts

what's the best way to go about highlighting C# keywords in a rich text box? Changing the ForeColor of the rich text box changes all the text, not certain words so I was thinking that each time a word is typed it would be added to an ArrayList. I could then write the elements in the ArrayList one by one after after checking if it was a keyword or not and if so change the text color of that word. Actually come to think of it, that idea wouldn't work either because how could I change the color of each word individually. Not to mention being highly inefficent. Anyone got any better ideas?
// I mean something like this, notice how certain words are highlighted.


while (true)
{
    /* Do stuff. */
}

public bool f(int i, char c)
{
     // ...

     return true;
} 
[edited by - template on November 13, 2003 9:32:47 PM]

Share this post


Link to post
Share on other sites