title: How to programatically dismiss the calendar of a DateTimePicker
body: <p>I am working on a Windows Form that uses a good amount of DateTimePicker controls.
  As per spec, the controllers need to show 'no date' initially till user manually selects a date.</p>
  
  <p>As per the DateTimePicker functionality, we cant assign 'nothing' as a value.
  So what we do is set a default minimum date, and then change the custom format of the control to "", to give the illusion of an empty field.</p>
  
  <p>A quirk we have found is that when the user clicks on the DateTimePicker and selects a new date for the first time, his initial click does not dismiss the calendar. So instead the calendar persists, and the user has to manually click outside the control to dismiss the calendar.</p>
  
  <p>To make the user experience slightly worse, while in this state the calendar is immune to any further date selection. So the date selection is stuck with the initially selected date, and the user needs to click out.</p>
  
  <p>Once a date has been selected by the control, selecting a new date dismisses the calendar as expected.</p>
  
  <p>My best guess would be that it would have something to do with the custom format that is there originally, which causes a hiccup with the control when a new properly formatted date is selected.</p>
  
  <p>I am trying to find a way to 'force' the calendar to dismiss if open on value change, but I am not finding the way to do this.
  I have even tried to set focus elsewhere on value change, but no luck either.</p>
  
  <p>Has anybody else experienced this behavior and/or know of a way around it?
  Thanks!</p>
  
  <p>Some of the code-----------</p>
  
  <pre><code>//if dateTime property has not been saved, then call ClearDateTime on the controller, else display the saved value.
  
  public static void ClearDateTime(DateTimePicker dtp)
      {
          dtp.Value = DateTime.Today.AddDays(-1);
          //set the format
          dtp.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
  
          // set custom format to empty
          dtp.CustomFormat = " " ;
      }
  
  // When value is changed/date is selected
  private void DateTimePicker_ValueChanged(object sender, EventArgs e)
      {
          MainFormUtilities.ShowDateTime(this.DateTimePicker);
          this.LockFormDown();
      }
  
  public static void ShowDateTime(DateTimePicker dtp)
      {
          dtp.Format = System.Windows.Forms.DateTimePickerFormat.Long;
      }
  </code></pre>