当我在richtextbox中输入一个字符时,我想从它的文本范围中获取下一个字符。
我是这样做的:
TextPointer ptr1= RichTextBox.CaretPosition;
char nextChar = GetNextChar();
//we continue until there is a character
while (char.IsWhiteSpace(nextChar))
{
ptr1= ptr1.GetNextInsertionPosition(LogicalDirection.Forward);
nextChar = GetCharacterAt(Ptr1);
}
//so now ptr1 is pointing to a character, and we do something with that TextPointer
ChangeFormat(ptr1);
然后我得到下一个字符的ptr1,从文本指针中,我得到文本范围,并进行修改。
问题就在这里?
当下一个单词拼写正确时,我没有问题,但是
如果拼写不正确
然后ptr1不会指向下一个单词的第一个字符(第二个字符),如果我使用getNextContextPosition(logicalDirection.Forward),如果拼写错误,它会给我下一个单词的第一个字母。所以根据拼写只有一个有效?
我只是想知道你是否知道这个问题?我在这里做错什么了吗?