title: C# DateTimePicker
body: <p>I have a WinForm with a DateTimePicker control on it showing a specific date from my SQL database.</p>
  
  <p>When the user clicks it, I have a custom form open to ask if they are sure they want to change the date. </p>
  
  <p>If they click OK they can proceed to change the date using the DateTimePicker and the changes are posted back to my SQL Server database.</p>
  
  <p>If the user clicks Cancel instead, the method exits so no changes are saved to the database.  </p>
  
  <p>However, what is annoying me, is even when the user clicks Cancel, the DateTimePicker drop down calendar stays open, which a user may interpret as the action having failed to Cancel.  How can I get the DateTimePicker to close an open drop down calendar?</p>
  
  <pre><code>private void datDOA_ValueChanged(object sender, EventArgs e)
      {
          frmConfirmBox frmCB = new frmConfirmBox("Are you sure you want to change the Date of Accident?");
          frmCB.ShowDialog();
          if (frmCB.intButton == 0)
          {                
              return;
          }
  
          datDOA.Format = DateTimePickerFormat.Long;
  
          //...Connect to Database...//
  
          string strCaseNo = txtCaseNo.Text;
          string strConnect = BuildConnectionString();
          SqlConnection linkToDB = new SqlConnection(strConnect);
          linkToDB.Open();
  
          //...Send User Input to Database...//
  
          DateTime dateNewDate = datDOA.Value;
          string commandText = "UPDATE tblCases SET DOA = @DOAVal WHERE CaseNo = @CaseNoVal;";
          SqlCommand sqlCom = new SqlCommand(commandText, linkToDB);
          sqlCom.Parameters.Add("@DOAVal", SqlDbType.DateTime);            
          sqlCom.Parameters.Add("@CaseNoVal", SqlDbType.VarChar);
          sqlCom.Parameters["@DOAVal"].Value = dateNewDate;
          sqlCom.Parameters["@CaseNoVal"].Value = strCaseNo;
          sqlCom.ExecuteNonQuery();
  
          linkToDB.Close();
      }        
  </code></pre>