This question is locked. New answers and comments are not allowed.
Hi there,
I've this code:
private void ReplaceAllMatches(string toSearch, string toReplaceWith,RadDocument doc)
{
doc.Selection.Clear();
DocumentTextSearch search = new DocumentTextSearch(doc);
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);
}
foreach (var textRange in rangesTrackingDocumentChanges)
{
doc.Selection.AddSelectionStart(textRange.StartPosition);
doc.Selection.AddSelectionEnd(textRange.EndPosition);
string textoSeleccionado = doc.Selection.GetSelectedText();
DocumentPosition posInicial = textRange.StartPosition;
DocumentPosition posFinal = textRange.EndPosition;
DocumentPosition posTotal = new DocumentPosition(posInicial);
//posTotal.MoveToCurrentLineStart();
//posTotal.MoveToCurrentWordStart();
doc.Insert(toReplaceWith,new Telerik.Windows.Documents.Model.Styles.StyleDefinition());
textRange.StartPosition.Dispose();
textRange.EndPosition.Dispose();
}
}
So I´ve the word that I want replace selected, how I can get that range to replace here, with RadDocument?
Thanks in advance,
I've this code:
private void ReplaceAllMatches(string toSearch, string toReplaceWith,RadDocument doc)
{
doc.Selection.Clear();
DocumentTextSearch search = new DocumentTextSearch(doc);
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);
}
foreach (var textRange in rangesTrackingDocumentChanges)
{
doc.Selection.AddSelectionStart(textRange.StartPosition);
doc.Selection.AddSelectionEnd(textRange.EndPosition);
string textoSeleccionado = doc.Selection.GetSelectedText();
DocumentPosition posInicial = textRange.StartPosition;
DocumentPosition posFinal = textRange.EndPosition;
DocumentPosition posTotal = new DocumentPosition(posInicial);
//posTotal.MoveToCurrentLineStart();
//posTotal.MoveToCurrentWordStart();
doc.Insert(toReplaceWith,new Telerik.Windows.Documents.Model.Styles.StyleDefinition());
textRange.StartPosition.Dispose();
textRange.EndPosition.Dispose();
}
}
So I´ve the word that I want replace selected, how I can get that range to replace here, with RadDocument?
Thanks in advance,