Actually, the proposed method for selecting an annotation should not change the caret position. I presume an additional action such as insertion is changing the position of the caret in your project. You can try subscribing to the PositionChanged event of the CaretPosition if you want to debug this.
The reason the caret position is not changed is that explicitly moving the caret position clears the selection by default. However, the DocumentSelection class provides you with the ability to select multiple Ranges at a time, so when you invoke methods like SelectAnnotationRange() you would not expect for the previous selection ranges to be cleared.
As an example of this, if you run the following code over a document containing multiple permission ranges all of them will be selected while the caret will not change its position:
Now, if you change the caret as follows:
all previously added selection ranges will be removed.
To further explain the point I made in my previous post, RadRichTextBox's API greatly depends on the caret position, so we usually do not recommend modifying its position manually by moving it unless moving the caret is exactly what you want to do. For all other purposes you can create a separate DocumentPosition.
Furthermore, in case you need to move the caret while preserving the selection, you can always create a DocumentSelection object in code and store the current document selection there while operating with the caret.
I hope this makes things clear! Let us know in case you have any additional comments.
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>