Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Double Click event to MonthCalendar

Status
Not open for further replies.

Denaeghel

Programmer
Apr 23, 2001
61
0
0
BE
Hello

I want to add a double click event to my MonthCalendar object.
I just simulated double click by the following code:

Private Sub MonthCalendar1_MouseDown(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
MonthCalendar1.MouseDown
Dim x As Date
If e.Button = MouseButtons.Left Then
If m_NumClicks = 0 Then
m_FirstClick = x.Now.Ticks
m_NumClicks += 1
ElseIf (x.Now.Ticks - m_FirstClick) > 10000000 Then
m_NumClicks = 0
Else
m_NumClicks += 1
ExecuteDoubleClick()
End If
End If
End Sub

But I can't use my mousedown event anymore and this won't work for my click event.

I have already inherit my MonthCalendar into my class
Created a new event

Public Class MyMonthCalendar
Inherits MonthCalendar

Public Event MyDoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs)

Public Shadows Sub DoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles
MyBase.DoubleClick
MessageBox.Show("DoubleClick")
End Sub
End Class


And on my form

Private Sub MonthCalendar1_MyDoubleClick(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles _
MonthCalendar1.MyDoubleClick
MessageBox.Show("MonthCalendar1_MyDoubleClick")
End Sub

But I get no reaction on the double click.

Can anyone tell me what I'm doing wrong by creating my new event.

Thanks

karel.denaeghel@barco.com
 
I see that I forgot something in my previous post.

Public Class MyMonthCalendar
Inherits MonthCalendar

Public Event MyDoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs)

Public Shadows Sub DoubleClick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles
MyBase.DoubleClick
MessageBox.Show("DoubleClick")
RaiseEvent MyDoubleClick(sender, e)[/color red]
End Sub
End Class


But still no reaction on double click!

karel.denaeghel@barco.com
 
Well, that's a problem.
I even tried this:
Code:
    Public Shadows Event DoubleClick(ByVal sender As Object, _
      ByVal e As System.EventArgs)

    Public Sub MyDoubleClick(ByVal sender As Object, _
      ByVal e As System.EventArgs) Handles MyBase.DoubleClick

        RaiseEvent DoubleClick(Me, EventArgs.Empty)

    End Sub
don't work!
The shadows we made is not helping because the code in the base class doesn't know about the shadowing (not like overrides).
My suggestion: catch the double click in the form context and check if the location of the mouse is in the calendar.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top