代码之家  ›  专栏  ›  技术社区  ›  shadeMe

RichTextBox未正确更新插入符号位置

  •  0
  • shadeMe  · 技术社区  · 16 年前

    我有一个处理程序使用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第一次调用时它所在的位置。重新绘制文本框似乎也没有任何效果。

    2 回复  |  直到 16 年前
        1
  •  0
  •   shadeMe    16 年前

    这个问题似乎已经解决了。不幸的是,不知道是什么导致了这种变化。正在关闭此线程。

        2
  •  -1
  •   riffnl    16 年前

    您没有指定新的长度(因此为:1-1=0)。尝试以下操作:

    推荐文章