我有一个处理程序使用WinForms RTB的keyDown事件,它有以下代码:
GetTextAtLoc(RTB->SelectionStart); // selects some text at the caret's position
RTB->SelectedText = "SomeOfMyOwn";
GetTextAtLoc(RTB->SelectionStart); // selects the replacement string
RTB->SelectionStart += RTB->SelectionLength - 1;
虽然这段代码似乎完成了它的工作(SelectionStart/Length属性得到了正确更新),但插入符号并没有移到新字符串的末尾—它说的是在GetTextAtLoc第一次调用时它所在的位置。重新绘制文本框似乎也没有任何效果。