using any key instead of TAB in textbox

Posted on 2005-04-13
Medium Priority
Last Modified: 2010-04-23
Any expert have idea ? cause using other key will make char input to textbox.text, but it should be a TAB key now.
Question by:macauken
LVL 32

Accepted Solution

Erick37 earned 60 total points
ID: 13771385
One way to catch key events is to set the form's KeyPreview property = True and then Override the OnKeyUp event.  Following example will convert the Enter key to a Tab key for all textboxes on the form.

    'Set the Form's KeyPreview property = True
    Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
        If TypeOf ActiveControl Is TextBox Then
            'Check for ENTER key
            If e.KeyCode = Keys.Enter Then
                'If ENTER pressed then process as TAB
                e.Handled = True
                Me.ProcessTabKey(Not e.Shift)
                'default handler
                e.Handled = False
            End If
        End If
    End Sub

Author Comment

ID: 13778230
I found the way soluation

  Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
            Select Case e.KeyChar
                Case "+"c
                    e.Handled = True
                Case "-"c 'Keys.Subtract
                    e.Handled = True
            End Select
        End Sub

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

578 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