views:

76

answers:

3

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?

A: 

How about a textfield with the format "7h 30m" (7 hours and 30 minutes)

LaZe
I would like it to be Localized and used with ease by users, with low or even none possibility for error.
MadBoy
+1  A: 

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

Henk Holterman
Thanks, will give it a spin :)
MadBoy
+2  A: 

If you're comfortable with it, I would build a custom control for this. Maybe a read only textbox where I display the formatted time spent, and 2 buttons, one for up, one for down that looked something like the old VB updown control. I'd suggest adding a minimum, maximum, and up / down interval properties also. This should be an easy enough control to do and it would go a long way towards simplifying the user input.

Beaner
I have no idea how to build custom controls :(
MadBoy
@MadBoy - It is not hard, here is a simple custom control tutorial: http://www.codeproject.com/KB/miscctrl/cutebutton.aspx. Have a look at it. Basically I am suggesting you combine several standard controls into one, add a few custom properties and enable you users to click an up button to add time in say 15 minute increments.
Beaner
Will give it a go when project is a bit more advanced. Right now i need to do it quickly, later on i'll tune things up. Thanks :)
MadBoy