Results 1 to 4 of 4

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

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2020
    Posts
    70

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

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

    Code:
    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.
    Last edited by IT_Researcher; Feb 9th, 2026 at 08:02 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width