using any key instead of TAB in textbox

Posted on 2005-04-13
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

    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

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    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…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now