Results 1 to 10 of 10

Thread: vb.net double click on button

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    19

    vb.net double click on button

    how to make double click on button mean you just click once time only

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: vb.net double click on button

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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    19

    Re: vb.net double click on button

    i want that just click once equal to double click...because i got special case...i dont want
    click twice button to execute something

  4. #4
    Registered User Vektor's Avatar
    Join Date
    Mar 2006
    Location
    Australia
    Posts
    34

    Re: vb.net double click on button

    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?

  5. #5
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: vb.net double click on button

    Why not do something like this:

    VB Code:
    1. dim Ch as Boolean
    2.  
    3. // click event
    4.  
    5. if ch <> true then
    6.     // code for one click
    7.     Ch= true
    8. else
    9.    // code for two clicks
    10.    Ch = false
    11. end if

    is that the sort of thing your looking for?

  6. #6
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: vb.net double click on button

    Quote Originally Posted by BradleyOng83
    i want that just click once equal to double click...because i got special case...i dont want
    click twice button to execute something
    Hi,

    You could also try this;

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    2.      
    3.      ' here your code what your button has to do
    4.      ' include next line
    5. Button1.Enable = False
    6.  
    7.     End Sub

    You can make your Button1 Enable again in another Click Event.
    Hope it's that what you want.

    sparrow1
    Last edited by sparrow1; Mar 18th, 2006 at 05:05 PM.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: vb.net double click on button

    try this for fun:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Static lastclick As Double = 0
    3.         Dim ThisClick As Double = DateAndTime.Timer
    4.         If ThisClick > lastclick + 0.5 Then
    5.             'do your single click stuff here
    6.             Debug.Print("Click")
    7.         Else
    8.             'do you doubleclick stuff here
    9.             Debug.Print("Double Click")
    10.         End If
    11.         lastclick = DateAndTime.Timer
    12.     End Sub

  8. #8
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: vb.net double click on button

    Quote Originally Posted by moeur
    try this for fun:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Static lastclick As Double = 0
    3.         Dim ThisClick As Double = DateAndTime.Timer
    4.         If ThisClick > lastclick + 0.5 Then
    5.             'do your single click stuff here
    6.             Debug.Print("Click")
    7.         Else
    8.             'do you doubleclick stuff here
    9.             Debug.Print("Double Click")
    10.         End If
    11.         lastclick = DateAndTime.Timer
    12.     End Sub
    Hi,

    I've got an error on the Debug.print line.

    'Print' is not a member of 'System.Diagnostics.Debug'.

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  9. #9
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: vb.net double click on button

    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
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  10. #10
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: vb.net double click on button

    Hi,

    I've solved the Error myself.
    Here is the result.

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Static lastclick As Double = 0
    3.         Dim ThisClick As Double = DateAndTime.Timer
    4.         If ThisClick > lastclick + 0.5 Then
    5.             TextBox1.Text = "First Click"
    6.  
    7.         Else
    8.             TextBox1.Text = "Second Click"
    9.  
    10.         End If
    11.         lastclick = DateAndTime.Timer
    12.  
    13.     End Sub
    Anyway thanks for this code, learned more.

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

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