Link to home
Start Free TrialLog in
Avatar of DenaMP
DenaMP

asked on

How to enable tabbing from hours to minutes in the datetimepicker?

I am a using quite a few datetimepickers set to a CustomFormat of military time:
         dtpTimeToYard.CustomFormat = Format("HH:mm")
The problem is that my users want to tab from the hours to the minutes portion and are very annoyed that they can't do this.  How do I give them this capablity?  I have told them that they can use the right arrow key but this does not appease them.  Thanks for your help!  
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

The Tab key is a dialog key, and requires special programming:

Convert Enter and Escape keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET
http://www.vb-helper.com/howto_net_enter_esc_to_tab.html
Example:
 
' Convert Enter and Escape keys
' into Tab and Shift-Tab.
' Thanks to Luis XV (luisxvarg@hotmail.com).
Protected Overloads Overrides Function _
    ProcessDialogKey(ByVal keyData As Keys) As Boolean
    Select Case keyData
        Case Keys.Enter
            Return MyBase.ProcessDialogKey(Keys.Tab)
        Case Keys.Escape
            Return MyBase.ProcessDialogKey(Keys.Shift Or _
                Keys.Tab)
    End Select
    Return MyBase.ProcessDialogKey(keyData)
End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DenaMP
DenaMP

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DenaMP
DenaMP

ASKER

On the other hand, I think my users will be thrilled if they can use the enter key that's on the number pad instead of the tab key.  But then, how should they navigate to from hours to minutes?  I don't want to use a non-intuitive character on the number pad.  Thanks for your help!
That post was only to show you the realm of possibilities, and not to be a specific answer to your question.  

Do you still need advice?
Avatar of DenaMP

ASKER

If you know of a way to use the Enter key instead of the Tab key and still have the Enter key jump from hours to minutes in the datetimepicker, that would be great.  Otherwise, I think I'm good.  Thanks so much for your help!  
Are you saying that this didn't work?


 Private Sub dtpTimeToYard_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dtpTimeToYard.KeyDown
               If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{RIGHT}")
        End If
    End Sub

Open in new window

Avatar of DenaMP

ASKER

It works, but not when I override the Enter key to act as a Tab key.  
I don't quite understand the problem.  Are you saying that you want the <Enter> key to tab to the next part of the control, or to another control?
Avatar of DenaMP

ASKER

Can it do both?
How would you like to do that exactly?

      hh<enter>mm<enter>ss<enter>  --> next control
Avatar of DenaMP

ASKER

Yes!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial