简体   繁体   English

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

[英]difference between LinkLabel.Click and LinkLabel.LinkClicked event?

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. 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.据我了解, Click事件会触发LinkClicked事件。

Why on earth have a LinkClicked event??为什么到底有一个LinkClicked事件? What's wrong with the Click event? Click事件有什么问题? Are there other ways to trigger LinkClicked besides clicking?除了点击还有其他方法可以触发LinkClicked吗?

Click will be raised if you click anywhere in the control.如果您Click控件中的任何位置,则会引发单击。 LinkClicked will be raised only if you click on a link area.只有当您单击链接区域时,才会引发LinkClicked Click will be raised in both cases (before LinkClicked if you click on a link).在这两种情况下都会引发Click (如果您点击链接,则在LinkClicked之前)。

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. 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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM