views:

567

answers:

3

I want to reset the time of a date time picker to 00:00 manually. When i select the date from it i get the time of the instance i select the time is there any way i can reset it to given time?

+3  A: 

How about this:

picker.Value = picker.Value.Date;

EDIT: To specify a particular time, you'd use something like:

TimeSpan time = new TimeSpan(3, 30, 0); // 3 hours and 30 minutes
picker.Value = picker.Value.Date + time;
Jon Skeet
damn thats good man had been searching something like where i can give some time values myself but this solves my problem any how .But still if you can give me a solution for giving time values myself that would be a great help i am thankful to you even for this :D
Mobin
Mobin: Have edited to show that (you could also use "AddHours" or something similar). If that's not what you meant, please explain and I'll see what I can do.
Jon Skeet
Sir thats exactly what i meant Thanks a lot :D:D
Mobin
A: 

Reset time to 00:00:00

dateTimePicker.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

Before reset:

2009-08-15 20:27:42

After reset

2009-08-15 00:00:00
mykhaylo
A: 

You could go to the designer and set the Value property of the DateTimePicker control to 00:00 - it will disappear in the designer, but the value will be 00:00.

Cosmo