how to make double click on button mean you just click once time only
Printable View
how to make double click on button mean you just click once time only
i suppose you could disable the button for a few milliseconds after the first click, on a timer or something.. ?? Once the interval is up, enable it again...
i want that just click once equal to double click...because i got special case...i dont want
click twice button to execute something
the Button control Click event is raised after a single click, so i'm not sure what you are after. Could you please be more specific?
Why not do something like this:
VB Code:
dim Ch as Boolean // click event if ch <> true then // code for one click Ch= true else // code for two clicks Ch = false end if
is that the sort of thing your looking for?
Hi,Quote:
Originally Posted by BradleyOng83
You could also try this;
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' here your code what your button has to do ' include next line Button1.Enable = False End Sub
You can make your Button1 Enable again in another Click Event.
Hope it's that what you want.
sparrow1
try this for fun:VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Static lastclick As Double = 0 Dim ThisClick As Double = DateAndTime.Timer If ThisClick > lastclick + 0.5 Then 'do your single click stuff here Debug.Print("Click") Else 'do you doubleclick stuff here Debug.Print("Double Click") End If lastclick = DateAndTime.Timer End Sub
Hi,Quote:
Originally Posted by moeur
I've got an error on the Debug.print line.
'Print' is not a member of 'System.Diagnostics.Debug'.
sparrow1
Hi,
I've solved the Error myself.
Here is the result.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static lastclick As Double = 0
Dim ThisClick As Double = DateAndTime.Timer
If ThisClick > lastclick + 0.5 Then
TextBox1.Text = "First Click"
Else
TextBox1.Text = "Second Click"
End If
lastclick = DateAndTime.Timer
End Sub
Anyway thanks for this code, learned more.
sparrow1
Hi,
I've solved the Error myself.
Here is the result.
Anyway thanks for this code, learned more.VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Static lastclick As Double = 0 Dim ThisClick As Double = DateAndTime.Timer If ThisClick > lastclick + 0.5 Then TextBox1.Text = "First Click" Else TextBox1.Text = "Second Click" End If lastclick = DateAndTime.Timer End Sub
sparrow1