RadDocument Insert in Selection range

2 posts, 0 answers
  1. Manuel
    Manuel avatar
    61 posts
    Member since:
    Oct 2011

    Posted 28 Dec 2011 Link to this post

    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,

  2. Boby
    Admin
    Boby avatar
    685 posts

    Posted 30 Dec 2011 Link to this post

    Hello Manuel,
    It looks you've found the answer in the other thread you opened. Don't hesitate to contact us if you have other questions.

    Kind regards,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top