We have a custom Find/Replace dialog for our RadRichTextBox. As part of the replacement of text, we have this code:
var startPos = Document.Selection.Ranges.First.StartPosition;
var endPos = Document.Selection.Ranges.First.EndPosition;
this
.CurrRichTextBox.Document.CaretPosition.MoveToPosition(endPos);
this
.CurrRichTextBox.Document.Selection.SetSelectionStart(startPos);
this
.CurrRichTextBox.Document.Selection.AddSelectionEnd(endPos);
StyleDefinition style =
new
StyleDefinition();
style.CopyPropertiesFrom(
this
.CurrRichTextBox.CurrentEditingStyle);
this
.CurrRichTextBox.Delete(
false
);
this
.CurrRichTextBox.Document.Insert(s, style);
However, this code uses the deprecated Insert method, and this also causes the history to be cleared. What is the now correct method for replacing text and maintaining the styling of the text? Can you please provide a code example? I have tried to search through documentation, but I could not find any examples.
Thanks, Bob