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

Recommended Answers

All 5 Replies

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

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

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..

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.