tags:

views:

16

answers:

2

Greetings

i am developing windows form using vs2010 c#

i have 2 datetime pickers

1 is fromDatePicker and the other is ToDatePicker

i want to validate that the toDate is always after from date are the same day

eg if From:30/8/2010...To:16/8/2010

an error message is showed to user

thnx

A: 

You can do comparisons on `DateTimes'

if (toDate < fromDate)
{
    MessageBox.Show("To date is before from date");
}

If you're not worried about the time portion then use the Date property:

if (toDate.Date < fromDate.Date)
{
    MessageBox.Show("To date is before from date");
}
ChrisF
A: 

Can you set a minimumDate property on your toDate control to the date on the fromDate control?

Beth