As I enter a character in my RichTextBox, I want to get the next character from the its TextRange.
So here is how I do it:
TextPointer ptr1= RichTextBox.CaretPosition;
char nextChar = GetNextChar();
while (char.IsWhiteSpace(nextChar))
{
ptr1= ptr1.GetNextInsertionPosition(LogicalDirection.Forward);
nextChar = GetCharacterAt(Ptr1);
}
then I get the ptr1 of the next character and from the TextPointer, I get the TextRange, and do my changes.
So here is the problem?
when the next word is spelled correctly, I have no problem, but if it's not spelled properly then ptr1 would not point to the first character of the next word (the second character), and if I use GetNextContextPosition(LogicalDirection.Forward) it would give me the first letter of the next word if it's misspelled. So depending on the spelling only one of them works?
I was just wondering if you have any idea about this problem? Is there anything wrong I am doing here?