Get content of highlighted text

2 posts, 0 answers
  1. arab
    arab avatar
    2 posts
    Member since:
    Nov 2016

    Posted 18 Nov 2016 Link to this post

    Hello,

    I want to use telerik toolbar with radrichtextbox, i want to import word document and highlight with the tollbar button a number of words.

    Then i want to get the content of theese words and to save it in an xml file.

    Question : How can i get the content of highlited text ? If you know another technology that can provides me with those features please tell me about it.

    Thank you.

  2. Tanya
    Admin
    Tanya avatar
    564 posts

    Posted 23 Nov 2016 Link to this post

    Hello Arab,

    You can check all the spans in the document and extract the text from the ones with a particular highlight color. The following snippet demonstrates how you can get the text from the spans highlighted with red color:
    List<string> highlightedStrings = new List<string>();
     
    foreach (var span in this.radRichTextBox.Document.EnumerateChildrenOfType<Span>())
    {
        if (span.HighlightColor == Colors.Red)
        {
            highlightedStrings.Add(span.Text);
        }
    }

    Hope this helps.

    Regards,
    Tanya
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top