Prevent double-click from double firing a command

前端 未结 14 1778
情书的邮戳
情书的邮戳 2020-12-15 08:34

Given that you have a control that fires a command:

Is there a way to prevent the command from being fired

14条回答
  •  离开以前
    2020-12-15 09:12

    If your control derives from System.Windows.Forms.Control, you can use the double click event.

    If it doesn't derive from System.Windows.Forms.Control, then wire up mousedown instead and confirm the click count == 2 :

    private void Button_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ClickCount == 2)
        {
           //Do stuff
        }
     }
    

提交回复
热议问题