Ben Ben - 1 year ago 60 Question

A good way in .NET Winforms to have user entered time frame?

Does anyone know of a good way to have a user enter an amount of time (hours and minutes) using winforms controls? At the moment I have two numeric up downs, one for time and one for minutes that I then parse to create a timespan. The only other idea I have is a text box that a user can enter a "00:00" time in, and validate the input. Both of these ways seem a bit bad (in UI terms) though.

Any ideas?


Answer Source

You can use a MaskedTextBox. This will allow you to have an input box with a format based on the mask you choose (e.g. __:__). This would be useful in the event that a time amount may be above 24 hours (which a DateTimePicker control wouldn't allow you to enter).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download