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).
Why does this unexpected behaviour happen and how to handle this?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 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.




Reply With Quote
