任务窗格中的 VSTO C# 可单击链接

VSTO C# Clickable Links in Task Pane

我的 Excel VSTO 插件有一个自定义任务窗格。在此任务窗格中,我想显示一个可单击的 link(例如“https://whosebug.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?

您需要处理 RichTextBox 的 LinkClicked 事件。

richTextBox1.LinkClicked += richtextBox1_LinkClicked;

public void richtextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
    // Opens the link in the default browser.
    Process.Start(e.LinkText);
}