Word Counts with RadRichTextBox

4 posts, 0 answers
  1. Dave
    Dave avatar
    32 posts
    Member since:
    Feb 2008

    Posted 04 Jun 2011 Link to this post

    Are there any methods or samples that demonstrate obtaining word counts from a RadDocument? 

  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 06 Jun 2011 Link to this post

    Hi Dave,

    You can use the GetStatisticsInfo method of RadDocument to obtain a DocumentStatisticsInfo object, which contains information about the following parameters as properties:
    • int PagesCount
    • int SectionsCount
    • int WordsCount
    • int CharactersCount
    • int SpacesCount
    • int ParagraphsCount
    •  int LinesCount
    You can see a sample use of the statistics in our online demo by choosing the "Show statistics" option from the view tab in the ribbon bar. The code of the demo is visible by checking the Source tab in the top-right corner. It is also included in the installation, under the "Demo" folder (located where your Binaries folder is).

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. John
    John avatar
    5 posts
    Member since:
    Jan 2012

    Posted 31 Jul 2013 Link to this post

    What happened to this method on the RadDocument API and the online demo?  I can't find either instance.  This method would prove very helpful for tracking the character count of a document.

  4. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 02 Aug 2013 Link to this post

    Hello John,

    The statistics option was indeed removed from the UI of the demos in the latest versions. However, you can easily add a button in the Ribbon UI and handle the click event like this:

    private void Statistics_Click(object sender, RoutedEventArgs e)
        DocumentStatisticsInfo statisticsInfo = this.radRichTextBox.Document.GetStatisticsInfo();
        MessageBox.Show(statisticsInfo.ToString(), "Document Statistics", MessageBoxButton.OK);

    You can also use the properties of the DocumentStatisticsInfo class to prepare a different string using the properties listed in my previous post.

    I hope this helps.

    Iva Toteva
    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 >>
Back to Top