Thanks, Seth. I pasted your code into my form and ran it. It
compiles without error, but it never fires. Can you take a look at
this and maybe point out where I am going wrong?
Imports System.Windows.Forms
Public Class Form3
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object,
ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Me.Text = "Order Reversed. Problem solved."
End Sub
Private Sub MonthCalendar1_MouseDown(ByVal sender As Object, ByVal
e As System.Windows.Forms.MouseEventArgs) Handles
MonthCalendar1.MouseDown
Me.Text = "Order NOT Reversed. Problem still exists."
End Sub
End Class
Public Class ExtendedMonthCalendar
Inherits MonthCalendar
Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseDown(e)
preventDateChanged = False
OnDateChanged(dateChangedEventArgs)
End Sub
Protected preventDateChanged As Boolean = True
Protected dateChangedEventArgs As DateRangeEventArgs
Protected Overrides Sub OnDateChanged(ByVal drevent As
System.Windows.Forms.DateRangeEventArgs)
Try
If preventDateChanged Then
dateChangedEventArgs = drevent
Else
MyBase.OnDateChanged(drevent)
End If
Finally
preventDateChanged = True
End Try
End Sub
End Class
Thanks again,
Randy
rowe_newsgroups - 15 Oct 2007 17:29 GMT
> Thanks, Seth. I pasted your code into my form and ran it. It
> compiles without error, but it never fires. Can you take a look at
[quoted text clipped - 46 lines]
> Thanks again,
> Randy
The code I gave you is a replacement for the MonthCalendar.
If I were you, I would add a new class file to my project (call it
ExtendedMonthCalendar.vb or something similar) and then place the code
I gave you there. Then, when you rebuild your project you should have
an ExtendedMonthCalendar item listed under <Project> Components in the
Toolbox. Then you can drag that component onto a form and use it as
normal.
If you want to replace your existing MonthCalendar, you pretty much
have two options. The first is to delete the existing control and
replace it with the new ExtendedMonthCalendar. This will be fairly
annoying if you have a lot of Event Handlers wired up to the calendar.
The second option is to open up the Designer.vb file for the "host"
form (or whatever) and modify the declaration for MonthCalendar1 to
use the ExtendedMonthCalendar class instead. By the way, to do this
you'll need to first click the "Show All Files" button on the solution
explorer. Then replace lines like "Private MonthCalendar1 As
MonthCalendar" and "MonthCalendar1 = New MonthCalendar()" with lines
like "Private MonthCalendar1 As ExtendedMonthCalendar" and
"MonthCalendar1 = New ExtendedMonthCalendar()"
Let me know how it works!
Thanks,
Seth Rowe
Charlie - 16 Oct 2007 21:56 GMT
I added a post to the thread you started on 10/7.
> Thanks, Seth. I pasted your code into my form and ran it. It
> compiles without error, but it never fires. Can you take a look at
[quoted text clipped - 46 lines]
> Thanks again,
> Randy