DateTimePicker question

Adagio

Well-known member
Joined
Dec 12, 2005
Messages
162
Programming Experience
Beginner
Does anyone here have an idea how to solve this problem:

What I would like is the possibility for the program to automatically change focus to another control as soon as the user has entered a date in the datatimepicker using the keyboard
The problem is I can't seem to find any events that runs when the user has entered the day/month/year
So far the only "solution" I can find is when the keydown event runs, you could see if the year has changed or if it's still the same, then if the year has changed it changes focus. But this doesn't work if the user writes 2007 in the year field when the value was already set to 2007
 
ValueChanged event, it is the default event which suggest that it is closely coupled to the main functionality of this control, ie selecting data values. Try doubleclicking any control in form and its default event handler is generated for you in code.
 
But as far as I can see it doesn't tell which value has changed (if it's day, month or year)
 
The Value of DateTimePicker control is type Date, if you change either part of the Date the value has changed.
 
Sounds like you need to capture the date value before the change, break it down into month, day, and year values and then use some if statements in the ValueChanged event comparing the previous values to the current values and changing focus when required.
 
But that doesn't solve the problem when a user writes the same as was already written
but the date didn't change if the date didn't change?
 
but the date didn't change if the date didn't change?


Which is the problem. For some people it's just much easier to just write in the datetimepicker field (like if it was a textbox), while others prefer to pick the date

What I'm trying to do is what you often see with textboxes that needs a date. You just write DD-MM-YYYY and as soon as the fourth digit of the year has been written the next textbox gets focus. For textboxes you can easily find the index of where the user is currently writing. What I'm looking for is to have the keyboard friendliness of using a textbox, while also making it easier to those who doesn't like to use the keyboard more than needed
 
"Keyboard-people" usually tab through the DTP and on to next field, they are very used to tabbing.
 
Usually yes, but not everybody and not always
If I was the end-user of this application I'm pretty sure that I often would love for it shift focus automatically as several of my forms only need input from the right side of the keyboard, and not needing to tab could free up my left hand for other stuff :)
...and I'm the kind of guy who uses tabbing all the time
 
Supposed for simplicity of this discussion you created your own dtp control, either a single (mask)textbox or one box for each date part. How would you decide in code that user was finished with the full date if only for example month was changed? The computer can't read minds. What if you decided when user wrote last char in mask, the last digit of the year for example, to move on to next field. I think the keyboard-people would be upset having to Shift-tab back and start the date field all over again when they really only wanted to delete the last digit and write the correct one and tab on to next field themselves like normal user-interfaces they are used to.

And bringing this auto-move-on-thought one step further, you have a regular text input field, there is no way to determine when user is finished inputting free text. Wouldn't that "break" the move-on user interface, only bringing inconsistency and misunderstanding for user? In one field they are pushed to another without wanting it, the next field they are sitting there waiting for the application to move them to next but nothing happens...
 
I think the keyboard-people would be upset having to Shift-tab back and start the date field all over again when they really only wanted to delete the last digit and write the correct one and tab on to next field themselves like normal user-interfaces they are used to.

Considering that in datetimepicker shift-tab brings you back to the last field that was active (which in this case would be year) that wouldn't cause any problems. And most "keyboard-people" I know would prefer to write the full year instead of deleting the last digit and write the correct number (or they could just use up or down if it was off by a single year)

How would you decide in code that user was finished with the full date if only for example month was changed?

I know the computer can't read minds, and in a situation like this I wouldn't do anything

And bringing this auto-move-on-thought one step further, you have a regular text input field, there is no way to determine when user is finished inputting free text. Wouldn't that "break" the move-on user interface, only bringing inconsistency and misunderstanding for user? In one field they are pushed to another without wanting it, the next field they are sitting there waiting for the application to move them to next but nothing happens...

The "when does the next control get auto-focus" problem will be solved by using the auto-focus in the same situations through out the program, so the users will "get used to which situations it will happen"


One of the reasons why I would like a feature like this is because the users who are going to use this program are already used to such feature in the old program they're using at the moment



But I guess there's no easy solution for this, so let's just bury this thread
 
Back
Top