更新时间:2023-12-06 14:18:34
使用 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();
}
}