VSTO C# Clickable Links in Task Pane

懵懂的女人 提交于 2021-01-29 06:02:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!