We have huge text being displayed inside a rich text box. We have implemented our custom Regular expression for advanced searches like Date > 1/1/200 which will look inside the text and will return say index of word for ex 1/12/2011, we represent it as word range which is essentially starting index and end index of the hit. Now I want to mix the above logic with highlighting infrastructure of the rich text box.
I m using the below code
But for some reason it fails.Can you please let me know if this hybrid highlight is possible?
Thanks,
Naga.
I m using the below code
ITextBasedDocumentFormatProvider
exporter = new TxtFormatProvider();
var documentTextMap = new DocumentTextMap(radRichTextBox.Document);
string text = exporter.Export((documentTextMap).Document);
WordHitEvaluator.WordRange[] wordRanges = wordHitEvaluator.Evaluate(text, fieldNames);
if (wordRanges != null)
foreach (WordHitEvaluator.WordRange wordRange in wordRanges)
{
TextRange textRange = documentTextMap.MapFromIndexInText(wordRange.Start,
wordRange.End - wordRange.Start);
radRichTextBox.Document.Selection.SetSelectionStart(textRange.StartPosition);
radRichTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
}
radRichTextBox.ChangeTextHighlightColor(
Colors.Red);
radRichTextBox.Document.Selection.Clear();
But for some reason it fails.Can you please let me know if this hybrid highlight is possible?
Thanks,
Naga.