How to get Highlighted Text in a RadRichTextBox

2 posts, 0 answers
  1. Joseph
    Joseph avatar
    135 posts
    Member since:
    Sep 2007

    Posted 02 Feb 2011 Link to this post

    Hi guys,

    I am trying to get the highlighted text in a RadRichTextBox.

    I can access the Selection object, but there is no property Text.

    richTextArea.Document.Selection

    Any suggestions ?

    Thanks.
  2. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 03 Feb 2011 Link to this post

    Hello Joseph,

    There is a method in DocumentSelection called GetSelectedText, so you can use something like this:
    string selectedText = richTextArea.Document.Selection.GetSelectedText();
    It is available as a method rather than a property to point that it's a relatively costly operation and repetitive calling should be avoided where possible.

    Kind regards,
    Ivailo
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top