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".
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