【发布时间】:2021-10-13 14:33:25
【问题描述】:
我在任务窗格中使用了 2016 VSTO 插件这个词。
在任务窗格中,我打开了我的网站的 URL,其中有一些外部超链接。
我的默认浏览器是谷歌浏览器,但外部链接仍然在 IE 中打开。
我尝试使用以下网址。
下面这个网址是说不可能的
How to set the default browser in word addin
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: ms-word vsto word-addins
我在任务窗格中使用了 2016 VSTO 插件这个词。
在任务窗格中,我打开了我的网站的 URL,其中有一些外部超链接。
我的默认浏览器是谷歌浏览器,但外部链接仍然在 IE 中打开。
我尝试使用以下网址。
下面这个网址是说不可能的
How to set the default browser in word addin
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: ms-word vsto word-addins
在任务窗格中,您可以使用LinkLabel 控件,该控件允许处理对链接的点击,并通过以下方式以编程方式运行系统的默认网络浏览器:
public void InitializeLinkControl()
{
// Create the LinkLabel.
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
// Configure the LinkLabel's location.
// this.linkLabel1.Location = new System.Drawing.Point(34, 56);
// Specify that the size should be automatically determined by the content.
this.linkLabel1.AutoSize = true;
// Add an event handler to do something when the links are clicked.
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
// Set the text for the LinkLabel.
this.linkLabel1.Text = "Visit Microsoft";
}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
// Specify that the link was visited.
this.linkLabel1.LinkVisited = true;
// Navigate to a URL.
System.Diagnostics.Process.Start("http://www.microsoft.com");
}
【讨论】:
WebView2 浏览器控件或/和处理代码中的超链接点击。