开发者

Valdiation From To date

I am developing Windows Form using vs2010 C#

I have 2 datetime pickers

1 is fromDatePicker and the other is 开发者_如何学CToDatePicker

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.


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");
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜