Search code examples
c#winformsdatetimepicker

Best aproach for working with Time in WinForms?


I'm trying to make a field where user will enter amount of time per day he/she spent on a project per day. It can be from 30 minutes to 8 hours. Is DateTimePicker with CustomFormat hh:mm best choice for this? Or there's better alternative for WinForms C#? Maybe TextBox or MaskedTextBox with special settings?


Solution

  • Although the MaskedTextBox is generally a pain, this is a situation it could be useful. With Mask="00:00". Give it a spin.

    And you will have to convert to/from text to TimeSpan yourself