Share via

Why does Button.DoubleClick not fire in WinForms when MouseUp opens another form?

test code 21 Reputation points
2026-02-09T12:50:29.1666667+00:00

In a VB.NET Winforms application, we have a button.

On button click i.e. Button1.MouseUp event, it opens another form.

But when we double click on the button, the double click splits into two single clicks i.e. first single click opens another form (Button1.MouseUp event) and second single click happens on the now opened form which shows a message (MyBase.MouseUp event).

This is the sample code for your reference:

Public Class Form1
    Private Sub Button1_MouseUp(sender As Object, e As EventArgs) Handles Button1.MouseUp
        Dim form = New Form1
        form.ShowDialog()
        form.Dispose()
    End Sub
    Private Sub Button1_DClick(sender As Object, e As EventArgs) Handles Button1.DoubleClick
        MsgBox("double click")
    End Sub
    Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
        MsgBox("Mouse Up")
    End Sub
End Class

Why does this unexpected behaviour happen and how to handle this?

Why isn't the Button1.DoubleClick event called on double clicking the button?

We tried giving sleep() before form.ShowDialog() but it made no difference. We also tried using PeekMessage in the child form's Load event to discard pending click messages from the message queue, but we are looking for alternative, cleaner methods.

Developer technologies | .NET | Other
{count} votes

3 answers

Sort by: Most helpful
  1. Jack Dang (WICLOUD CORPORATION) 14,955 Reputation points Microsoft External Staff Moderator
    2026-02-10T04:31:26.01+00:00

    Hi @test code ,

    Thanks for reaching out.

    The Button.DoubleClick event often doesn’t fire if the first click changes the UI, such as opening a new form, because a double-click requires two consecutive clicks on the same button. In your case, the first click opens a new form, so the second click lands on that new form instead, and the double-click event never gets triggered.

    Also, as noted in the official docs (thanks to Castorix31 for pointing this out; see the Remarks section here: Button.DoubleClick), WinForms buttons don’t have the standard double-click behavior enabled by default. Internally, the ControlStyles.StandardClick and ControlStyles.StandardDoubleClick bits are false for Button, which is why the DoubleClick event isn’t reliably raised. While it’s technically possible to change these style bits in a custom button, doing so is rarely practical and doesn’t solve scenarios where the first click changes the UI (like opening a form).

    A clean and reliable way to handle single vs double clicks is to use the MouseUp event and inspect e.Clicks. For example:

    Private Sub Button1_MouseUp(sender As Object, e As MouseEventArgs) Handles Button1.MouseUp
        If e.Button = MouseButtons.Left Then
            If e.Clicks = 2 Then
                ' Double-click action
                MsgBox("Double click detected!")
            ElseIf e.Clicks = 1 Then
                ' Single-click action
                Dim form = New Form1
                form.ShowDialog()
                form.Dispose()
            End If
        End If
    End Sub
    

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.


  2. Castorix31 91,741 Reputation points
    2026-02-09T13:44:36.7166667+00:00

    Why isn't the Button1.DoubleClick event called on double clicking the button?

    It is explained in Remarks : https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.button.doubleclick?view=windowsdesktop-10.0&redirectedfrom=MSDN#remarks

    You must change the style...

    0 comments No comments

  3. Q&A Assist
    2026-02-09T12:50:41.2+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The behavior you're observing occurs because the MouseUp event is processed before the DoubleClick event can be triggered. In Windows Forms, a double-click is recognized by the system based on the timing of two consecutive clicks. When you double-click the button, the first click triggers the MouseUp event, which opens another form. This interrupts the double-click detection, causing the second click to be processed as a single click on the newly opened form instead of being recognized as part of a double-click on the original button.

    To handle this situation, you can modify your approach by using the Click event instead of MouseUp to open the new form. The Click event is fired after the double-click detection logic has completed, allowing the DoubleClick event to be triggered correctly. Here’s how you can adjust your code:

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim form = New Form1
            form.ShowDialog()
            form.Dispose()
        End Sub
    
        Private Sub Button1_DoubleClick(sender As Object, e As EventArgs) Handles Button1.DoubleClick
            MsgBox("double click")
        End Sub
    
        Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
            MsgBox("Mouse Up")
        End Sub
    End Class
    

    By using the Click event, you ensure that the double-click functionality works as intended, and the new form will open only when the button is clicked, not on the MouseUp event.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.