I need to determine if the calendar drop-down is displayed in WinForms DateTimePicker. I have a custom control that inherits DateTimePicker, and I am handling the KeyDown event to do things with the navigation keys, but I would like to get around this code if the calendar drop-down is open, so the user can use their navigation keys there.
Using a ComboBox control, it is easy to use a property .DroppedDownto verify that it has opened, but DateTimePicker does not have this property.
I am currently doing the following:
Private _isDroppedDown As Boolean = False
Private Sub MyDateTimePicker_CloseUp(sender As Object, e As EventArgs) Handles Me.CloseUp
_isDroppedDown = False
End Sub
Private Sub MyDateTimePicker_DropDown(sender As Object, e As EventArgs) Handles Me.DropDown
_isDroppedDown = True
End Sub
However, I would like to know if there is a better way to get the state of the DroppedDown control than manually tracking it with a variable?