TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
David Pullman
NA
11
0
HTML Editor Character color help
Apr 6 2009 11:35 AM
Hey guys, I'm making an HTML editor. I want to be able to have the HTML tags show up as a different color than the rest of the text. For example:
<p>Hello C#!</p>
I want the paragraph tags to be highlighted as a different color as the text (which is black by default).
I was thinking of something like this.
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
string text = richTextBox1.Text;
char[] sep = { ' ', '\n', '.', ',', ':', ';' };
string[] words = text.Split(sep, System.StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < text.Length; i++)
{
if (text[i] == '<')
{
//change color of tag here
}
}
}
Thats just a rough idea. I know I'm gonna have to add code that will loop through the text and when it finds the '<' loop through the characters there and then stop the color change with the '>' character is found. I know it needs a lot of work, but I'm kinda new at this. Any suggestions or help. If I can get this to work I would be so happy. I've been messing with it for a while. Please let me know.
-Dave
Reply
Answers (
7
)
Write XML without overwriting
day month year problem