DateTime.TryParse Method (System) | Microsoft Docs[
^]
This method is perfect to know whether a string is a valid datetime representation.
protected override void OnLostFocus(EventArgs e)
{
base.OnLostFocus(e);
if (DateTime.TryParse(Text, out DateTime theDate))
{
}
else
{
MessageBox.Show("Invalid Date");
}
}
As a side note: why not using a DateTimePicker instead, which is the control specifically designed to input and display datetime values?