Can I use LinkLabel on Visual Studios to link to a windows form?

夙愿已清 提交于 2019-12-05 17:18:26

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