I have a custom task pane for my Excel VSTO addin. In this task pane I want to display a clickable link (for example "https://stackoverflow.com") to the user which opens the user's browser and navigates to the site when clicked. When I programmatically put the text into the task pane's RichTextBox the text turns blue as if it is being recognized as a URL, however when the text is clicked on nothing happens. Is there a property I need to set for the RichTextBox to allow the link to be clicked on?
Asked
Active
Viewed 192 times
0

Braxvan
- 67
- 14
-
It seems like `RichTextBox` is present in both WinForms and WPF (this can be used with ElementHost, if you're not already aware). I suggest altering the tags to match whichever you're using. `vsto` and `excel` are not relevant in this case. – Chris Oct 12 '18 at 18:00
-
It's a WinForms project, I will change the tags to reflect this. – Braxvan Oct 12 '18 at 18:40
1 Answers
1
You need to handle the LinkClicked
event of the RichTextBox.
richTextBox1.LinkClicked += richtextBox1_LinkClicked;
public void richtextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
// Opens the link in the default browser.
Process.Start(e.LinkText);
}

Handbag Crab
- 1,488
- 2
- 8
- 12