Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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;    
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top