问题
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?
回答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);
}
来源:https://stackoverflow.com/questions/52784009/vsto-c-sharp-clickable-links-in-task-pane