How can I get the DateTimePicker popup state?

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?

+3
2

, , , / , .

.Tag . , , , . , , "MyDateTimePicker", :

Public Class MyDateTimePicker
    Inherits DateTimePicker

    Dim _isDroppedDown As Boolean = False

    Public Property IsDroppedDown() As Boolean
        Get
            IsDroppedDown = _isDroppedDown
        End Get
        Set(value As Boolean)
            _isDroppedDown = value
        End Set
    End Property

    Private Sub MyDateTimePicker_CloseUp(sender As Object, e As System.EventArgs) Handles Me.CloseUp
        _isDroppedDown = False
    End Sub

    Private Sub MyDateTimePicker_DropDown(sender As Object, e As System.EventArgs) Handles Me.DropDown
        _isDroppedDown = True
    End Sub

End Class

MyDateTimePicker "" . , , DateTimePickers, .IsDroppedDown.

, , , DLL, .

+2

, ; .

( , . DTP.)

0