Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.

In my winforms, i have a DateTimePicker.
what i want to do is put a validation that if the a selected date has already been passed then it should give an error.
I want to put this in an else if statement like

if(DateTimePicker Validation here)
{
C#
TxtToolStrip.Text = "Date entered has passed";
                DateTimePicker.Focus();


}

Now i dont know what code to type. Can someone please help me out. Thanks everyone.
Posted

1 solution

C#
if (myDateTimePicker.Value < DateTime.Now)
   {
   ...
   }
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Dec-11 4:30am    
Sure, a 5.
--SA
Humayun Kabir Mamun 12-Dec-11 6:14am    
the above solution will be work fine.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900