954,153 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Validating DateTimePicker

I need to make sure that when the user select a date from a DateTimePicker the date should not be less than Today's date,

anyone knows how to achieve that

Thanx

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

On change event, in datatime picker, compere date with Now().CurrentDate();

uim_1977
Light Poster
25 posts since Oct 2008
Reputation Points: 46
Solved Threads: 0
 

Im not sure if Im doing it right but... I have changed the datetimepicker to ValueChanged so now I dont have compare option to compare the datetimepicker with Now().CurrentDate()

PLease let me know if u have an idea

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

not shure exacly what did you do with the data picked in datatimepicker, but still you suposed to have the picked data samwhere, theather way what is the poitn of using the picker..

uim_1977
Light Poster
25 posts since Oct 2008
Reputation Points: 46
Solved Threads: 0
 

I have a datetime picker, then I have ValueChanged event handler for it and a code that goes like this

DateTime date = DateTime::Parse(dtpDate->Text);
System::DateTime::Compare(date, System::DateTime::Today.Now);

but now its trhowing exception that said date is not valid I cant even open my form

Traicey
Posting Whiz in Training
283 posts since Mar 2008
Reputation Points: 26
Solved Threads: 19
 

what is tis line suposed to asign to varible date ?

DateTime date = DateTime::Parse(dtpDate->Text);


why do you try to compere it in this way ?
try instad

if (Now().CurrentDate()<DateTimePicker1->Date) 
{
//your code
}

in onchange event

uim_1977
Light Poster
25 posts since Oct 2008
Reputation Points: 46
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You