Selection Text Major Bug

7 posts, 0 answers
  1. ATIF
    ATIF avatar
    1 posts
    Member since:
    Jan 2012

    Posted 11 Aug 2014 Link to this post

    Radrichtextbox we are facing little problem which i need your help, Might i am missing something or this is internal bug.We area trying to get complete document text with all punctuation etc.Code snippet is give below all code work fine if document does not have any punctuation or quotation, But for instance if there is any word likewise.

    Telerik is great,

    so the code would discard great, because it has comma code is given below please its a request help me on this issue and give me chance of thanks.

                DocumentPosition position = new DocumentPosition(this.MacroRichTextBox.Document);            do            {                  var id = position.GetCurrentSpanBox();                if (!(id ==null))                {                    string word = position.GetCurrentSpanBox().Text;
                        DocumentPosition wordEndPosition = new DocumentPosition(position);                    wordEndPosition.MoveToCurrentWordEnd();                    this.MacroRichTextBox.Document.Selection.AddSelectionStart(position);                    this.MacroRichTextBox.Document.Selection.AddSelectionEnd(wordEndPosition);                }            } while (position.MoveToNextWordStart()); 

    ATIF SHAHZADSoftware Developer 
  2. Svetoslav
    Admin
    Svetoslav avatar
    55 posts

    Posted 14 Aug 2014 Link to this post

    Hello Atif,

    Thank you for contacting us.

    Let me get straight to the question. In order to select the entire content in a document I would suggest you to use the following approach: 

    this.radRichTextBox.Document.Selection.SelectAll();
    You can also get the selected content like this:

    this.radRichTextBox.Document.Selection.GetSelectedText();
     I hope this information is helpful. Don't hesitate to contact us again if you have further questions.

    Regards,
    Svetoslav
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Atif shahzad
    Atif shahzad avatar
    6 posts
    Member since:
    Mar 2010

    Posted 06 Sep 2014 in reply to Svetoslav Link to this post

    First of all thank you so much for the response, Well i have very complex scenario which i need to explain it in more detail.

    I have headings on left side of the document and each heading have descriptions like given below.

    Skin: This is normal.

    Eyes: No problem found.

    Now if user click on hyperlink like Skin/Eyes so i want to get the description of particular item.

    If user click on Skin so i want to select the Skin description only.

    If user click on Eyes so i wan to to select the Eyes description only.

    I have done that and my algorithm works fine if description does not contain any special character like  
    , . ;  :  / , If description contain any special character so it does not work correctly i have attached two images kindly help me it is very critical for my application Thanks.

     

     
  5. Svetoslav
    Admin
    Svetoslav avatar
    55 posts

    Posted 10 Sep 2014 Link to this post

    Hello Atif,

    Actually I am still not sure why you need to select every single word separately. If you are trying to extract some text I would suggest to read the document by paragraphs and implement some logic for the extracted text with the methods of String:
    DocumentPosition position = new DocumentPosition(this.radRichTextBox.Document);
     
    do
    {
    DocumentPosition paragraphEndPosition = new DocumentPosition(position);
    paragraphEndPosition.MoveToLastPositionInParagraph();
    this.radRichTextBox.Document.Selection.AddSelectionStart(position);
    this.radRichTextBox.Document.Selection.AddSelectionEnd(paragraphEndPosition);
    position = paragraphEndPosition;
    while(position.MoveToNext()); 
     
    string text = this.radRichTextBox.Document.Selection.GetSelectedText();
     
    Alternatively here is how to get the text of a line:
    DocumentPosition position = new DocumentPosition(this.radRichTextBox.Document);
     
    do
    {
    DocumentPosition lineEndPosition = new DocumentPosition(position);
    lineEndPosition.MoveToCurrentLineEnd();
    this.radRichTextBox.Document.Selection.AddSelectionStart(position);
    this.radRichTextBox.Document.Selection.AddSelectionEnd(lineEndPosition);
    position = lineEndPosition ;
     } while(position .MoveToNext());

    string text = this.radRichTextBox.Document.Selection.GetSelectedText();

    Please let me know if you need further assistance.

    Regards,
    Svetoslav
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Atif shahzad
    Atif shahzad avatar
    6 posts
    Member since:
    Mar 2010

    Posted 10 Sep 2014 in reply to Svetoslav Link to this post

    Got it, Now i have only one issue left regarding Find/Replace.
    If i want to Find  string which contains circle brackets () so find function does not work in code behind, it only works if i use find/replace dialog but i want to find using Code behind sample code are given below.

    1.foreach (var textRange in search.FindAll("We are (fine)"))
    2.       {
    3.           this.MacroRichTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
    4.           this.MacroRichTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
    5.            this.radRichTextBox.Insert("Hurra!");
    6.       }
  7. Svetoslav
    Admin
    Svetoslav avatar
    55 posts

    Posted 12 Sep 2014 Link to this post

    Hi Atif,

    The FindAll() method uses the accepted search string as a regex. That said, you can simply escape your search string. More information is available in the Search article.

    I hope this helps. 

    Regards,
    Svetoslav
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  8. Atif shahzad
    Atif shahzad avatar
    6 posts
    Member since:
    Mar 2010

    Posted 17 Sep 2014 in reply to Svetoslav Link to this post

    Thank you so much it really helps.
Back to Top
DevCraft banner