我有一个使用 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 第一次调用时的位置。重绘文本框似乎也没有任何效果。