Approved
Last Updated: 27 Aug 2019 13:15 by ADMIN
Rick
Created on: 20 Aug 2019 14:40
Category: RichTextBox
Type: Feature Request
1
RichTextBox: Advanced Find Options

In MS Word there are several options available in the Advanced Find dialog that are not available in the RichTextBox, the two most requested by our users are "Match case" and "Find whole words only".

1 comment
ADMIN
Martin
Posted on: 27 Aug 2019 13:15

Hi Rick,

Thank you for the detailed information. I logged this issue in our backlog and updated your Telerik points as a token of appreciation for your cooperation.

Until this feature is developed you can use a custom Find and Replace Dialog. Check in our SDK examples for the CustomFindReplaceDialog, which can be modified to provide such functionality. The workaround is to alter the FindNext(DocumentPosition fromPosition) method, using the result of the custom created checkboxes to in the "Match case" case to use the second constructor of the DocumentTextSearch class which accepts RegexOptions and in the "Find whole words only" case to change the searched text with the relevant Regular expression pattern. 

public void FindNext(DocumentPosition fromPosition)
{
            ...
            DocumentTextSearch textSearch;
            if (this.matchCaseFlag)
            {
                this.options = RegexOptions.None;
                textSearch = new DocumentTextSearch(this.Document, this.options);
            }
            else
            {
                textSearch = new DocumentTextSearch(this.Document);
            }

            TextRange find;
            if (this.matchWholeWordsOnlyFlag)
            {
                var wholeWordSearchText = string.Format("\\b{0}\\b", this.GetSearchText());

                find = textSearch.Find(wholeWordSearchText, fromPosition);
            }
            else
            {
                find = textSearch.Find(this.GetSearchText(), fromPosition);
            }
            ...
}

Regards,
Martin
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.