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
2009-08-15 18:08:04
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
2009-08-15 18:14:04
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
2009-08-15 18:23:50
Sir thats exactly what i meant Thanks a lot :D:D
Mobin
2009-08-15 19:00:51
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
2009-08-15 18:28:59
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
2009-10-18 11:00:39