Hello, sorry if this is posted in the wrong section of the forum.
Now, my question is simple.
I want to find and replace text(strings) in a document, I've tried using the following code:
But I get two errors, "document.DeleteRange() is obsolete use RadDocumentEditor.Delete() instead." and "document.Insert() is obsolete use RadDocumentEditor.InsertInline() instead.".
I can't figure out how to use these functions instead so that's why I need help!
I've never used this library before so all help is very appreciated.
Best regards
Isak
Now, my question is simple.
I want to find and replace text(strings) in a document, I've tried using the following code:
private
void
ReplaceAllMatches(RadDocument document,
string
toSearch,
string
toReplaceWith)
{
DocumentTextSearch search =
new
DocumentTextSearch(document);
List<TextRange> rangesTrackingDocumentChanges =
new
List<TextRange>();
foreach
(var textRange
in
search.FindAll(toSearch))
{
TextRange newRange =
new
TextRange(
new
DocumentPosition(textRange.StartPosition,
true
),
new
documentPosition(textRange.EndPosition,
true
));
rangesTrackingDocumentChanges.Add(newRange);
}
RadDocumentEditor docEdit =
new
RadDocumentEditor(document);
foreach
(var textRange
in
rangesTrackingDocumentChanges)
{
document.CaretPosition.MoveToPosition(textRange.StartPosition);
document.DeleteRange(textRange.StartPosition, textRange.EndPosition);
StyleDefinition style =
new
StyleDefinition();
style.SetPropertyValue(Span.ForeColorProperty, Colors.Red);
document.Insert(toReplaceWith, style);
textRange.StartPosition.Dispose();
textRange.EndPosition.Dispose();
}
}
But I get two errors, "document.DeleteRange() is obsolete use RadDocumentEditor.Delete() instead." and "document.Insert() is obsolete use RadDocumentEditor.InsertInline() instead.".
I can't figure out how to use these functions instead so that's why I need help!
I've never used this library before so all help is very appreciated.
Best regards
Isak