This is a migrated thread and some comments may be shown as answers.

Update LinkText

1 Answer 30 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 28 Jun 2014, 09:25 PM
Hello!

I am using RadRichTextBox, and in my scenario user can add hyperlinks to RichText to some application entities. Those entities can change their names outside of the richtextbox, so I need to update hyperlink text with corresponding data. But documentation about HyperlinkRangeStart does not give any clues how to update hyperlink text.

Can someone please tell me how can I accomplish my task?

WBR,
Dmitry.

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 01 Jul 2014, 02:59 PM
Hello Dmitry,

There is no API which allows to directly edit a hyperlink. I'd suggest you select the hyperlink and replace it instead. The below snippet shows how this can be achieved using the HyperlinkRangeStart of the first link in a document.
string newText = "NEW TEXT";
HyperlinkRangeStart start = this.radRichTextBox.Document.EnumerateChildrenOfType<HyperlinkRangeStart>().FirstOrDefault();
 
if (start != null)
{
    this.radRichTextBox.Document.Selection.SelectAnnotationRange(start);
    var info = start.HyperlinkInfo;
 
    this.radRichTextBox.InsertHyperlink(info, newText);
}

I hope this helps.

Regards,
Petya
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.
 
Tags
RichTextBox
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or