hi everyone. I want to delay the click event in a vsFlexgrid so that the double click event will run 1st. I used a timer for the delay in the click event and managed to get the value of the double click speed in the windows library for the timer interval. however i still cant make it work the way I want to. Its still running the click event rather than running the double click event 1st. hope you can enlighten me with this. here's my code.

''General Declaration
Declare Function GetDoubleClickTime Lib "user32" () As Long

''Form Declaration

Private Sub Form_Load()

      clickSpeed% = GetDoubleClickTime
      Timer1.Enabled = False
      Timer1.Interval = clickSpeed%

End Sub

Private Sub FlexGrid1_Click()

    Timer1.Enabled = True

End Sub

''It's not passing this event
Private Sub FlexGrid1_dblClick()

    Timer1.Enabled = False

    MsgBox "double click"

End Sub

Private Sub Timer1.Timer()

    Timer1.Enabled = False

    MsgBox "single click"

End Sub

Recommended Answers

All 5 Replies

I don't know if you don't receive any compile error on line 2 also, but I do.
Your code on line 28 will also give you an error.

I'm not really sure if what you want to happen is this:

Nothing will happen on single click, only if flexgrid is clicked 2x. If that's what you want, then:

Private Sub Form_Load()

    clickSpeed% = GetDoubleClickTime
    Timer1.Enabled = False
    Timer1.Interval = clickSpeed%

End Sub
Private Sub FlexGrid1_Click()

    Timer1.Enabled = True

End Sub

Private Sub FlexGrid1_dblClick()

    Timer1.Enabled = False
    MsgBox "double click"

End Sub
Private Sub Timer1_Timer()

    Timer1.Enabled = False
    MsgBox "single click"

End Sub

Actually what i want is if I double clicked the flex grid a message box "double click" will come out, but if i only click it once message box "single click" will appear. but the problem is only the single click command is executing and im not getting the message box "double click" that i want to see.

And yup, im not getting any error on line 2 nor line 28. "user32" may differ on other device. i think.

Try the following...

Private Sub FlexGrid1_dblClick()
    ''Use an if statement to check if the timer is enabled...

    If Timer1.Enabled = True Then
        Timer1.Enabled = False
        MsgBox "double click"
    End If
End Sub

I think your problem might be a limitation of VB. When there is both a click event handler and a doubleclick event handler the doubleclick never triggers because the first click is trapped by the click event handler.

If there is code in the Click event, the DlbClick event will never trigger, because the Click event is the first event to trigger between the two. As a result, the mouse click is intercepted by the Click event, so the DblClick event doesn't occur.

That's the quote from the MSDN article about click events.

Thanks for your help guys. Actually the codes i posted on the top works. It just got affected when i did not put "flexgrid1.Editable = flexEDKbdMouse" after the sinlge click command execute. silly me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.