1
votes

I want to get the Caret position in RichTextBox in WPF when I change my cursor with Left Click Mouse Button and this picture below shows this.

enter image description here

1
TextPointer caretPos = rtb.CaretPosition;?vik_78
I want to the position change when I use right/left/up/down key Without writing The picture i set illustrates this.Jon

1 Answers

0
votes

Get position:

TextPointer tp = EditMessageRTB.Selection.Start; 

Set position:

RichTextBox.CaretPosition = tp;

If want to set position to end:

RichTextBox.CaretPosition = RichTextBox.Document.Blocks.LastBlock.ContentEnd;