0

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   ? ? ?

}
2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Jennifer84
0
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 =]

0

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 =]

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.