This code is written inside a textBox event handler like this.
What happens is that when you have written the word: "Hello" wich consists
of 5 characters, this word will be selected, change color of "Hello" to blue, deselect the word and put the cursors position after the word Hello.
This is happening step by step.


The problem is that when the word "hello" is turned blue everything after will also be written in blue.
What I want is to change back the color for text that will be written after to black again so on the last line I wonder how to do this.

private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) 
{

   int positionen = 0;
   positionen = textBox1->SelectionStart;

   this->textBox1->Select(0, 5);
   this->textBox1->SelectionColor = Color::Blue;
   this->textBox1->DeselectAll();
   this->textBox1->SelectionStart = positionen;
   this->textBox1   ? ? ?

}

Recommended Answers

All 2 Replies

int positionen = 0;
positionen = textBox1->SelectionStart;
this->textBox1->Select(0, 5);
this->textBox1->SelectionColor = Color::Blue;
this->textBox1->DeselectAll();
this->textBox1->SelectionStart = positionen;
this->textBox1->SelectionColor = Color::Black;

Hope it helps =]

Thanks this will help :)

int positionen = 0;
positionen = textBox1->SelectionStart;
this->textBox1->Select(0, 5);
this->textBox1->SelectionColor = Color::Blue;
this->textBox1->DeselectAll();
this->textBox1->SelectionStart = positionen;
this->textBox1->SelectionColor = Color::Black;

Hope it helps =]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.