首页 文章

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

提问于
浏览
0

我有一个Excel VSTO插件的自定义任务窗格 . 在此任务窗格中,我想向用户显示一个可点击的链接(例如“https://stackoverflow.com”),该用户打开用户's browser and navigates to the site when clicked. When I programmatically put the text into the task pane'的RichTextBox,文本变为蓝色,就像它被识别为URL一样,但是当单击任何文本时发生 . 我需要为RichTextBox设置一个属性,以允许点击链接吗?
enter image description here

1 回答

  • 1

    您需要处理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);
    }
    

相关问题