RichEditBox Text einfärben

jkallup

Erfahrenes Mitglied
Hallo,

wie kann ich die beiden "Test" strings in der Zeichenkette "test des testens test" farbig hervorheben?
mit folgenden code habe ich leider kein erfolg gehabt:
verwende VS2005
Danke für Hilfe.

Code:
private: System::Void richTextBox1_TextChanged(System::Object^  sender, System::EventArgs^  e)
			 {
				int idx;
				
				idx = this->richTextBox1->Find("test", RichTextBoxFinds::WholeWord);
				if (idx >= 0)
				{
					this->richTextBox1->Select(idx,4);
					this->richTextBox1->SelectionFont = gcnew System::Drawing::Font("Verdana", 12, FontStyle::Bold);
					this->richTextBox1->SelectionColor = Color::Red;
				} else {
					this->richTextBox1->SelectionColor = Color::Black;
				}
				
				this->richTextBox1->Select(this->richTextBox1->Text->Length,0);
				this->richTextBox1->SelectionColor = Color::Black;
				this->richTextBox1->ScrollToCaret();
			 }
 
Zurück