Reputation: 335
How does one go about checking if a DateTimePicker
Control is currently displaying its calendar?
By comparison, checking a ComboBox
to see if its drop down list is displayed is so simple:
if (comboBox.DroppedDown)
//do something
Any ideas on how to achieve the same result for a DateTimePicker
's calendar?
Upvotes: 1
Views: 2581
Reputation: 66479
I don't see one either. You could create a bool to indicate whether it's dropped down.
Set it to true
in the DropDown
event.
Occurs when the drop-down calendar is shown.
Set it to false
in the CloseUp
event.
Occurs when the drop-down calendar is dismissed and disappears.
I noticed the snippet you typed in your question:
if (comboBox.DroppedDown)
//do something
If you're just trying to do something when the calendar is displayed, put your code in (or call your code from) the DropDown
event.
Upvotes: 4
Reputation: 3786
You can try implenting your self
private void DateTimePicker1_DropDown(object sender,
System.EventArgs e)
{
myVar = true;
}
private void DateTimePicker1_CloseUp(object sender,
System.EventArgs e)
{
myVar = false;
}
Upvotes: 1