Trailing blanks in hyperlinks

2 posts, 0 answers
  1. Michael Shaich
    Michael Shaich avatar
    4 posts
    Member since:
    Sep 2009

    Posted 19 Dec 2012 Link to this post

    Hi:

    I'm having issues when users create hyperlinks with trailing blanks.  I can avoid this in some cases where the blanks are at the end of the line.  I programatically remove the trailing blanks from the selected text parameter in the InsertHyperlink call.  That works great.  However, when the selected text is not at the end of the line, the characters of the link run together with the next word.  So how can I determine if a trailing blank is at the end of a line?

    Example
    Text line = "Now is the time "
    If the user selects "time " and inserts a link there, the trailing blank is not included in the link.  That is good.
    However, if the user double-clicks "the", "the " is highlighted automatically.  When a link is inserted, the resulting line looks like this:
    "Now is thetime".  So in this case, I don't want to trim the text I specify when I insert the link.  How do I tell?  The documentmodel is pretty complex.

    Thanks!

  2. Boby
    Admin
    Boby avatar
    595 posts

    Posted 26 Dec 2012 Link to this post

    Hello Michael,
    You can check if a DocumentPosition is at the end of the line by creating temporary copy and move it to the end of the line:
    DocumentPosition selectionEnd = this.radRichTextBox.Document.Selection.Ranges.First.EndPosition;
    DocumentPosition position = new DocumentPosition(selectionEnd);
    position.MoveToCurrentLineEnd();
     
    if (position == selectionEnd)
    {
         
    }

    We will log your your problem as feature request and will try to implement it in some of the future releases. We have added points to your account for the suggestions. Don't hesitate to contact us if you have other questions.


    Kind regards,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top