LinkLabel.Click 和 LinkLabel.LinkClicked 事件之间的区别?

发布于 2024-11-29 12:35:33 字数 487 浏览 9 评论 0原文

根据 http://msdn.microsoft.com/en -us/library/system.windows.forms.linklabel.aspxLinkLabel 类具有继承自的 Click 事件System.Windows.Forms.ControlLinkClicked 事件。据我了解,Click 事件将触发LinkClicked 事件。

到底为什么要有 LinkClicked 事件? Click 事件出了什么问题?除了点击之外还有其他方式触发LinkClicked吗?

According to http://msdn.microsoft.com/en-us/library/system.windows.forms.linklabel.aspx, the LinkLabel class has both a Click event inherited from System.Windows.Forms.Control and a LinkClicked event. From my understanding, Click event will trigger the LinkClicked event.

Why on earth have a LinkClicked event?? What's wrong with the Click event? Are there other ways to trigger LinkClicked besides clicking?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

意中人 2024-12-06 12:35:33

如果您单击控件中的任意位置,则会引发 Click。仅当您单击链接区域时才会引发LinkClicked。在这两种情况下都会引发 Click(如果您单击链接,则在 LinkClicked 之前)。

Click will be raised if you click anywhere in the control. LinkClicked will be raised only if you click on a link area. Click will be raised in both cases (before LinkClicked if you click on a link).

真心难拥有 2024-12-06 12:35:33

LinkClicked 事件具有特定的 LinkLabelLinkClickedEventArg,允许您不仅仅是响应 Click 事件,用户单击控件上的任何位置而不仅仅是链接部分都可以触发该事件。

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    // Specify that the link was visited.
    this.linkLabel1.LinkVisited = true;

    var target = e.Link.LinkData as string;
    System.Diagnostics.Process.Start(target);
}

The LinkClicked event has specific LinkLabelLinkClickedEventArg that allows you to do more than responding to the Click event, which could be fired by the user clicking anywhere on the control not just the link part.

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    // Specify that the link was visited.
    this.linkLabel1.LinkVisited = true;

    var target = e.Link.LinkData as string;
    System.Diagnostics.Process.Start(target);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文