How do I move the caret a certain number of positions in a WPF RichTextBox?

后端 未结 3 1238
梦如初夏
梦如初夏 2021-01-05 04:44

I want to move the caret 4 positions to the right of where my caret currently is. I\'m registered for PreviewKeyDown, and calling InsertTextInRun()

3条回答
  •  隐瞒了意图╮
    2021-01-05 05:42

    To test, you could try forcing the movement yourself:

    rtb.CaretPosition = rtb.Document.ContentEnd;
    

    If that works, you'll probably have to implement additional logic for situations where the tab is not at the end of the content.

提交回复
热议问题