How to set time in a DateTimePicker control where i have already changed the display format = Time
I want to make the DateTimePicker to display time that i set.
e.g. set it to 5:30 PM
I try but fail using:
DateTimePicker1.Value = New DateTime(0, 0, 0, 5, 30, 0) 'fail at runtime
Try setting the date portion of the new DateTime to the current date:
DateTimePicker1.Value = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 5, 30, 0 )
Then, when you want to read the value just take the time portion of the DateTime. The date portion has to be set to some value but since you are only displaying the time it doesn't really matter what it is.