0
votes

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?enter image description here

1
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
It's a WinForms project, I will change the tags to reflect this. - Braxvan

1 Answers

1
votes

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);
}