Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to set the time of the date time picker to 12:00 AM for all the selected dates.

All your advices are appreciable!
Posted
Updated 12-Dec-10 2:50am
v2

DateTimePicker.Value = new DateTime(You take it from here[^] );
 
Share this answer
 
v2
How about something like this:
C#
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "12:00 dd MMMM yyyy";

Or maybe it should be:
dateTimePicker1.CustomFormat = "'12:00' dd MMMM yyyy";


http://msdn.microsoft.com/en-us/library/h2ef6zxz.aspx[^]

Good luck!
 
Share this answer
 
v2
myDateTimePicker.Value = myDateTimePicker.Value.Date;
 
Share this answer
 
Comments
[no name] 10-Dec-10 14:33pm    
And how does this answer the question?
Toli Cuturicu 10-Dec-10 15:48pm    
Straightforewardly.
[no name] 10-Dec-10 17:55pm    
And if the date needs to be set? What happens when a value is already present? Better for design, readbility and maintenance to explicitly set the value.
Toli Cuturicu 11-Dec-10 7:20am    
And if the date needs to be set? myDateTimePicker.Value = DateTime.Today;
What happens when a value is already present? See my answer!
Better for design, readbility and maintenance to explicitly set the value. Of course. That is what I do.
[no name] 11-Dec-10 10:48am    
"See my answer" doesn't explain anything. If the date needs to be set independent of the time what happens? If a value already exists that is not 12:00 AM what happens?
"Of course. That is what I do" then why are you giving advice otherwise?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900