• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

How do you make an html editor like this?

Is there any way to have a richtextbox that when you type "<html>" it colors that text only and not the rest of the text?
Please help,
Joseph
0
JoeTheCoinMan
Asked:
JoeTheCoinMan
  • 2
1 Solution
 
lakshman_ceCommented:
Find for the tag and color it before loading to your form

Sample code

RichTextBox* richTextBox1 = new RichTextBox();
richTextBox1->Dock = DockStyle::Fill;
richTextBox1->LoadFile(S"C:\\IssuesSystem.rtf",RichTextBoxStreamType::RichText);
richTextBox1->Find(S"<html>", RichTextBoxFinds::MatchCase);
richTextBox1->SelectionColor = Color::Red;
this->Controls->Add(richTextBox1);
0
 
JoeTheCoinManAuthor Commented:
So there is no way to do this as the user types?
0
 
lakshman_ceCommented:
There is a way but it would be after the completion of <html> tag

1. Handle the RichTextBox_TextChanged event
2. Get the text in the richtextbox
3. Find the string <html> in it
4. change the color

void richTextBox1_TextChanged(Object* /*sender*/, EventArgs* /*e*/) {
{
richTextBox1->Find(S"<html>", RichTextBoxFinds::MatchCase);
richTextBox1->SelectionColor = Color::Red;
}


0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now