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


    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?

    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.


  2. Boby
    Boby avatar
    637 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);
    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,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top