resetting datetimepicker's date

doraemon

Freshman
Joined
Oct 3, 2003
Messages
36
I am using a datetimepicker for the users to enter dates. I have the "ShowCheckBox" to be true so that if there is no date to be entered, the check box would be uncheckd. I came across with a problem. When the form is cleared, the user would like to have the date resetted to the current date. However, after I set the value to the current date, the check box is automatcially checked for me. I even have a line of code setting the Checked property to False right afterward but the box would still be checked. Is there soemthing I've done wrong? Right now I'm just forced to leave with the existing value and just set the Checked property to False. But the user would prefer to have it reset. Any suggestion?
 
I tried the code (using VB equivalent). One thing funny I noticed was that if the datetimepicker was not checked and after running these 2 lines of codes, the check mark would be on. So, I have to add a condition to see if the datetimepicker is checked and if so the 2 lines would be executed; otherwise, nothing would happen. It is really weird that such a condition is put in. I don't know if it's a bug on the control.


Cags said:
I tried using the following...
C#:
dateTimePicker1.ResetText();
dateTimePicker1.Checked = false;

and it worked fine. It both reset the date and unchecked the box.
 
Back
Top