There are 3 parts to accomplishing this, all quite easy.
First up, you’ll want to subscribe to the TextBox’s Leave event.
Next, you would need to read the value from the TextBox and convert it into
a DateTime class, easiest way to do that is with the static Parse() method
that is part of the DateTime class.
Finally, output the LongDate format by calling the ToLongDateString() method
on the instance you just created.
All in all, the majority of your code would look not unlike:
private void myTextBox_Leave(object sender, System.EventArgs e)
{
DateTime enteredDate = DateTime.Parse(myTextBox.Text);
textBox1.Text = enteredDate.ToLongDateString();
}
One note, it would be wise to do some sort of checking prior to the Parse(),
or at least wrap it in a try/catch block just incase the user puts in an
invalid date that it chokes on.
Brendan
"Mike L" wrote:
After the user enter in short date in text box, once the user tabs out of the
text box I want the short date to change automatically to long date. What is
the code to make this change and what is the best event to put it in?