Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

How I can replace a certain text with a table

$
0
0

I would replace the text %Doctors% at the runtime by a table. The following code does not work.

private void ReplaceAllMatches(string Parameter, Telerik.Windows.Documents.Model.Table NewTable)
{
this.myViewer.Document.Selection.Clear(); // this clears the selection before processing
DocumentTextSearch search = new DocumentTextSearch(this.myViewer.Document);
List<Telerik.Windows.Documents.TextSearch.TextRange> rangesTrackingDocumentChanges = new List<Telerik.Windows.Documents.TextSearch.TextRange>();
foreach (var textRange in search.FindAll(Parameter))
{
Telerik.Windows.Documents.TextSearch.TextRange newRange = new Telerik.Windows.Documents.TextSearch.TextRange(new DocumentPosition(textRange.StartPosition, true), new DocumentPosition(textRange.EndPosition, true));
rangesTrackingDocumentChanges.Add(newRange);
}
foreach (var textRange in rangesTrackingDocumentChanges)
{
this.myViewer.Document.Selection.AddSelectionStart(textRange.StartPosition);
this.myViewer.Document.Selection.AddSelectionEnd(textRange.EndPosition);
this.myViewer.InsertTable(NewTable,true);
textRange.StartPosition.Dispose();
textRange.EndPosition.Dispose();
}
}

 


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>