cursor current position for radrichtextbox?

4 posts, 0 answers
  1. Shiv
    Shiv avatar
    9 posts
    Member since:
    Apr 2012

    Posted 09 May 2012 Link to this post

    How to get the cursor current position for radrichtextbox?

    like the Silver light control text box has property SelectionStart to get the current position of the cursor.
  2. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 11 May 2012 Link to this post

    Hello,

    You can access the current caret position through the RadDocument.CaretPosition property. More on this you can learn in the online help articles on positioning and selection.

    Greetings,
    Ivailo Karamanolev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Brian
    Brian avatar
    73 posts
    Member since:
    Sep 2010

    Posted 18 May 2012 Link to this post

    I am having an issue with positioning the cursor via the .MoveToPosition() method.  When I do this, the cursor gets placed correctly, but the document window adjusts so that the cursor is the last line that is shown. 

    For example, my RadRichTextBox displays 10 lines at any given time and I have 50 lines of text in the document.  If I move the cursor to a place in the text that is on the 30th line, it will put the 30th line at the bottom of the display.  I would like for it to put the selected line in the middle of the displayed area OR not move the display at all, just move the cursor.

    Hope this makes sense....

    Tks.

  5. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 23 May 2012 Link to this post

    Hi Brian,

    A ready-to-use method for such functionality is not available out of the box. However you can use the following code:

    DocumentPosition positionYouWantTheCaretOn = ...//logic finding the needed position
    this.editor.Document.CaretPosition.MoveToPosition(positionYouWantTheCaretOn );
    this.editor.ScrollToVerticalOffset(this.editor.Document.CaretPosition.Location.Y - this.editor.ActualHeight / 2);

    I hope this helps.

    Greetings,
    Andrew
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top