Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

This is a very simple question for most of you. I was searching in web for the whole day and I'm not able to get the answer which I want.

Help me!

I have a DateTimePicker. Its Custom Format "hh:mm tt".

Now if someone changed the value in DateTimePicker e.g 12:33 AM, I need move the date to 12:35 AM.

On event LostFocus I'm able to retrieve all the information:
DateTimePicker.Value().Hour
DateTimePicker.Value().Min

and manipulate the values, whether to increase or decrease.

Now, how do I assinged back the modified values to DateTimePicker

DateTimePicker.Value() = ??????


Thanks,
Skunkhead :)
Posted
Updated 18-Jul-17 9:29am
v3

Would be simpler to handle DateTimePicker.ValueChanged, and then re-set the value if it does not match your filter criteria (this if-check is important to avoid an endless loop of event raising event raising event).
 
Share this answer
 
Comments
skunkhead 10-Feb-11 21:17pm    
ok. thanks

how do i assign back the changed value back to DateTimePicker?
Nish Nishant 10-Feb-11 22:03pm    
Set the Value property.
skunkhead 10-Feb-11 22:05pm    
yes. I got it know. thanks Nishant.
Nish Nishant 10-Feb-11 22:06pm    
You're welcome.
Sergey Alexandrovich Kryukov 11-Feb-11 11:18am    
My 5, advanced advice,
--SA
Almost.

VB
MyDateTimePicker.Value = DateTime.Now


The property Value (property, not function!) is if the type DateTime which has all the time arithmetic operation you need. Do arithmetic with DateTime, not DataTimePicker, read or write the value of Value at once.

—SA
 
Share this answer
 
Comments
skunkhead 10-Feb-11 22:06pm    
thanks SA.
Sergey Alexandrovich Kryukov 11-Feb-11 11:17am    
You're welcome, thank you for accepting my answer
--SA

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