Validating DateTimePicker

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Validating DateTimePicker

 
1
  #1
Oct 27th, 2008
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
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Re: Validating DateTimePicker

 
0
  #2
Oct 27th, 2008
On change event, in datatime picker, compere date with Now().CurrentDate();
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Validating DateTimePicker

 
0
  #3
Oct 27th, 2008
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
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Re: Validating DateTimePicker

 
0
  #4
Oct 27th, 2008
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..
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 268
Reputation: Traicey is an unknown quantity at this point 
Solved Threads: 19
Traicey's Avatar
Traicey Traicey is offline Offline
Posting Whiz in Training

Re: Validating DateTimePicker

 
0
  #5
Oct 27th, 2008
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
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Re: Validating DateTimePicker

 
0
  #6
Oct 27th, 2008
what is tis line suposed to asign to varible date ?
  1. DateTime date = DateTime::Parse(dtpDate->Text);

why do you try to compere it in this way ?
try instad
  1. if (Now().CurrentDate()<DateTimePicker1->Date)
  2. {
  3. //your code
  4. }
in onchange event
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC