title: TextBox Date Format in C#
body: <p>I want to use as a DatetimePicker. I want to validate for date format. i am using keypress event to validate. the following code is written in KeyPress event. </p>
  
  <pre><code> DateTime temp;
          if (DateTime.TryParse(textBox1.Text, out temp))
          { textBox1.Text = temp.ToShortDateString(); }
          else
          { errorProvider1.SetError(textBox1, "Format dd/MM/yyyy"); }
  </code></pre>
  
  <p>but after entering date and month it automatically gives year also i don't want it like that.</p>
  
  <p>User can enter full date.</p>