gpt4 book ai didi

c# - 链接标签打不开

转载 作者:太空宇宙 更新时间:2023-11-03 16:20:56 24 4
gpt4 key购买 nike

我正在使用相同的代码在 Form2 和 Form3 中创建 LinkLabel。 Form2 和 Form3 是单独的类,因此名称不会干扰。它们都已创建,但在 Form 3 中打开链接,在 Form2 中没有任何反应。

这是Form2的代码

public partial class Form2 : Form
{
public void createFormEntry(List<string> videoId)
{
LinkLabel link = new LinkLabel();
link.Name = "link";
link.AutoSize = true;
link.Location = new Point(76, 8);
link.Text = "www.example.com";
link.LinkClicked += new LinkLabelLinkClickedEventHandler(link_LinkClicked);
this.Controls.Add(link);
}

private void link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.example.com");
}
}

这是给 Form3 的

public partial class Form3 : Form
{
private void createFormEntry(Feed<Video> videoFeed)
{
LinkLabel link = new LinkLabel();
link.Name = "link";
link.AutoSize = true;
link.Location = new Point(76, 8);
link.Text = "www.example.com";
link.LinkClicked += new LinkLabelLinkClickedEventHandler(link_LinkClicked);
this.Controls.Add(link);
}

private void link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.example.com");
}
}

他们在不同的类(class)。 Form2 在 Form3 之前打开。有什么问题吗?

编辑:现在当我添加更多代码时,我在 Form2 中看到 createFormEntry 是公共(public)的,而在 Form3 中它被设置为私有(private)的。这可能是一个原因吗?

最佳答案

你试图打开一个链接而不告诉程序如何或用什么打开该链接。你应该告诉它在程序或其他东西中搜索它!

关于c# - 链接标签打不开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13906471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com