DateTimePicker Events don't fire
VS 2005 Beta2:
I like the DateTimePicker, but it seems the events don't fire, neither click, doubleclick, mouseclick, mousedoubleclick seem to fire.
Are these events not yet implemented, does one need to click at a particular location or do I do anything else wrong?
Thanks - Thomas
[296 byte] By [
ThomasM] at [2008-2-15]
There is no magic to the code:
The DateTimePicker is placed on a form by drag and drop. The designer declares it as follow:
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePickerI assume when I click or doubleclick the DateTimePicker at least one of the messageboxes should show:
Private Sub DateTimePicker1_ClickEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.DoubleClick, DateTimePicker1.Click
MessageBox.Show("DateTimePicker ClickEvent Fired")
End Sub
Private Sub DateTimePicker1_MouseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DateTimePicker1.MouseDoubleClick, DateTimePicker1.MouseClick
MessageBox.Show("DateTimePicker MouseEvent Fired")
End Sub
Thanks - Thomas
You're correct - these events don't work. The Windows Forms implementation is a wrapper on a Windows OS provided DateTimePicker control. The underlying control does special mouse capturing that prevents us from properly providing these events (we will hide them in the PropertyGrid for VS 2005).
As a work-around, try using MouseUp and MouseDown.
Joe