How to set DateTimePicker only edit time ?

  • Thread starter Thread starter cyshao
  • Start date Start date
C

cyshao

How to set DateTimePicker only edit time ?

There is a DateTimePicker whoes Format = Time.

I find it only displys as time edit, but in fact, this control still control
Full DateTime when you click the button.

I mean if I enter 08:12:00, I want to get 08:12:00 only, not 1998-12-01
08:12:00.

How can I do that ?

Thanks

Charles shao
 
How to set DateTimePicker only edit time ?

There is a DateTimePicker whoes Format = Time.

I find it only displys as time edit, but in fact, this control still control
Full DateTime when you click the button.

I mean if I enter 08:12:00, I want to get 08:12:00 only, not 1998-12-01
08:12:00.

How can I do that ?

Change the ShowUpDown property to true to prevent the drop calendar from
being displayed. The value that you get out of it will still be a DateTime
object, but you can get only the time portion of that easy enough if that
is all you want. Use one of the members on the DateTime object that gets
just the time (ToShortTimeString(), ToLongTimeString(), TimeOfDay, Hour,
Minute, Second, etc).
 
Back
Top