DocumentTextSearch hanging at find function

2 posts, 0 answers
  1. mohd azidi
    mohd azidi avatar
    1 posts
    Member since:
    Sep 2014

    Posted 14 Feb Link to this post

    hi, im using current Telerik WPF Q1 2015 and also try using current and i have a problem in my project with DocumentTextSearch. the function is to load  document xaml template and find text string and replace with table. but i have problem with DocumentTextSearch when searching text string from RadDocument its keep hanging when try to find text string. my code is like bellow : 

      public void ReplaceTable(ref RadDocument doc, string searchitem, Table RefTable)
            {
                doc.BeginUpdate();
                try
                {
                    using (DocumentPosition startFindPosition = new DocumentPosition(doc.DocumentLayoutBox, true))
                    {
                        var found = true;

                        while (found)
                        {
                            DocumentTextSearch textSearch = new DocumentTextSearch(doc);
                            TextRange find = textSearch.Find( Regex.Escape(searchitem), startFindPosition);

                            found = find != null;

                            if (found)
                            {
                                startFindPosition.MoveToPosition(find.EndPosition);
                                startFindPosition.AnchorToNextFormattingSymbol();

                                doc.CaretPosition.MoveToPosition(find.StartPosition);
                                find.SetSelection(doc);

                                //doc.Delete(false);
                                //doc.IncreaseLeftIndent();
                                //if (RefTable.Rows.Count == 1)
                                //{
                                //    doc.Insert("-");

                                //}
                                //else
                                //{
                                //    doc.InsertTable(RefTable);
                                //}
                                doc.Selection.Clear();


                                startFindPosition.RemoveAnchorFromNextFormattingSymbol();
                            }
                        }
                       
                    }
                }
                catch (Exception e) { }
                finally
                {
                    doc.EndUpdate();
                    
                }
            }

    i wait your reply

     

  2. Svetoslav
    Admin
    Svetoslav avatar
    55 posts

    Posted 17 Feb Link to this post

    Hi,

    Thank you for contacting us.
     
    I tested the attached code snippet but it seems that it is working as expected on my end. My guess is that the problem could be related to incorrectly structured document. For this reason, I would ask you to send us exact steps to reproduce, document file and the searched text. Once we are able to reproduce the issue, we will do our best to assist you. 

    Regards,
    Svetoslav
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top