Share via


Resetting DateTimePicker

Question

Thursday, May 19, 2005 8:46 PM

I am clearing (resetting) a bunch of textboxes, checkboxes and stuff on a page with a button click.  I also need to reset the values of two DateTimePickers on the page to default value, but I can't seem to find the right syntax or something.

In the "Start Over" button click event, I've tried without avail:



        dtpRepFrom.Value.Now.ToString()
        dtpRepFrom.Value.Now.ToString()

 

As a side note, I have a checkbox whose enabledness depends on ValueChanged one or the other or both of the DateTimePickers.  That's not the only reason for wanting to reset the date/time though.  And maybe resetting it will give it another ValueChanged and disable it again, I dunno.

Thanks,
CP

All replies (2)

Thursday, May 19, 2005 9:28 PM ✅Answered

Try this:



dtpRepFrom.Value = Date.Now;

 

However, be aware that this will raise the ValueChanged event.


Thursday, May 19, 2005 9:38 PM ✅Answered

Thanks Dave,  will you be my new best friend?

I also found another one that works just as well.



dtpRepFrom.ResetText()

 

Doesn't seem terribly fitting to use ResetText for a calendar, but it does the trick.

And to avoid the ValueChanged event firing problem, I just re-enable the checkbox in the "Start Over" button's click event.  No biggie.

CP