How to validate date time picker(custom control) for from date to to date
how to validate date time picker "from date" to "To date " and To date should not be greater than From date . me using date time picker its a custom control developed by someone it not contain "valuechanged event" and close up event". initially this
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


EhteshamRank #3,979 · 374 reputationPosted Oct 11, 2012, 3:42 AM EDT
DateTime startdate = StartdateTimePicker.Value;
DateTime enddate = EnddateTimePicker.Value;
int v = startdate.CompareTo(enddate);
switch (v)
{
case -1:
MessageBox.Show("Valid");
break;
case 0:
MessageBox.Show("both dates are equal");
break;
case 1:
MessageBox.Show("Invalid");
break;
}