我可以在Visual Studios上使用LinkLabel链接到Windows窗体吗? [英] Can I use LinkLabel on Visual Studios to link to a windows form?

查看:172
本文介绍了我可以在Visual Studios上使用LinkLabel链接到Windows窗体吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在谷歌上查找如何使用linklabel链接到Windows窗体。我遇到的所有教程只链接到URL或本地磁盘。有帮助吗?我不想使用按钮。

I have been looking up on google to find out how to use linklabel to link to a Windows Form. All the tutorials that I've come across only link you to a URL or you local disk. Any help? I don't want to use buttons.

推荐答案

使用 LinkLabel 正如您将使用按钮一样,通过在click事件中执行代码。当用户单击标签时,以编程方式打开表单(或者如果它打开则将其带到前面)。您将无法设置表单的URL。

Use the LinkLabel as you would be using a button, by executing code in the click event. Open the form (or bring it to the front if it is alreay open) programmatically when the user clicks the label. You will not be able to set an URL to a form.

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    Form2 form2 = Application.OpenForms.OfType<Form2>().FirstOrDefault();
    if (form2 == null) {
        form2 = new Form2();
        form2.Show();
    } else {
        form2.BringToFront();
    }
}

这篇关于我可以在Visual Studios上使用LinkLabel链接到Windows窗体吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆