I have a coming back problem that I dont know how to get out from.
If you put this code in the event handler for a richtextBox control and write this on the First line:
1234567890 //This will turn red when you press 0
If you instead right away press enter so you come to the second line in the multilined textBox and write this:
123456789 //Then this will turn red when you press 9
So it seems that it uses the /n next line character as a character.
What I wonder is how this is possible to to solve as I want the code to only count the characters on the current line where the cursor is, so it would be: 1234567890 for all lines.
I use this code in the richtextBox event handler:
int positionen = 0;
positionen = richtextBox1->SelectionStart;
if ( richtextBox1->SelectionStart >= 10 )
{
this->richtextBox1->Select((positionen - 10), positionen);
this->richtextBox1->SelectionColor = Color::Red;
this->richtextBox1->DeselectAll();
this->richtextBox1->SelectionStart = positionen;
}