?
Solved

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

Posted on 2009-02-18
12
Medium Priority
?
301 Views
Last Modified: 2013-11-26
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!  
0
Comment
Question by:DenaMP
  • 6
  • 6
12 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23688372
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

0
 

Accepted Solution

by:
DenaMP earned 0 total points
ID: 23691532
Thanks so much for replying to my neglected question.  I tried your suggestion, but I need the tab key to act like an right arrow key and jump from the hours to the minutes field in the datetimepicker.  In all other controls I need the tab key to act like the tab key.  In the end, I just settled on capturing the key_down event for the Enter key (which is on the number pad).      
Thanks again for your help!

  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

0
 

Author Comment

by:DenaMP
ID: 23691704
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!
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 96

Expert Comment

by:Bob Learned
ID: 23693515
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?
0
 

Author Comment

by:DenaMP
ID: 23710725
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!  
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23711746
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

0
 

Author Comment

by:DenaMP
ID: 23711775
It works, but not when I override the Enter key to act as a Tab key.  
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23711793
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?
0
 

Author Comment

by:DenaMP
ID: 23711810
Can it do both?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23711824
How would you like to do that exactly?

      hh<enter>mm<enter>ss<enter>  --> next control
0
 

Author Comment

by:DenaMP
ID: 23711840
Yes!
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 1200 total points
ID: 23712028
The problem with that kind of functionality is that you have no idea where you are in the control.  There would be no way to distinguish that you are on the last part, and you need to tab, instead of right arrow.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question