Results 1 to 6 of 6

Thread: [RESOLVED] nullify {tab} key action

  1. #1

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Resolved [RESOLVED] nullify {tab} key action

    with vb.net 05 + datagridview

    in my datagidview i am having a button column
    i want the button to execute some actions when the enter button is pressed
    but if i press the enter button tab key action coming in to force i,e focus is getting shifted to next row hence i want to lock the tab key action and let the button to its click event job

    how to do it please
    and any adverse effect please advise

  2. #2
    Addicted Member
    Join Date
    Mar 2010
    Location
    Southeast Michigan
    Posts
    155

    Re: nullify {tab} key action

    How about using the keydown event of the datagrid?
    Code:
        Private Sub dg_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dg.KeyDown
            If e.KeyCode = Keys.Return Then
                MessageBox.Show("enter pressed. do stuff here")
                e.Handled = True
            End If
        End Sub
    Dave

    Helpful information I've found here so far : The Definitive "Passing Data Between Forms" : Restrict TextBox to only certain characters, numeric or symbolic :
    .NET Regex Syntax (scripting) : .NET Regex Language Element : .NET Regex Class : Regular-Expressions.info
    Stuff I've learned here so far : Bing and Google are your friend. Trying to help others solve their problems is a great learning experience

  3. #3

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Question Re: nullify {tab} key action

    thanks for reply

    what job this line will do, does it triggering the click event :
    Code:
    e.Handled = True
    my intention is to trigger some action, as if i am clicking the button

  4. #4
    Addicted Member
    Join Date
    Mar 2010
    Location
    Southeast Michigan
    Posts
    155

    Re: nullify {tab} key action

    Setting it to true bypasses the default handling of the enter key, which would be to move to the next row. I believe you'd trigger the action you want on the line where I've displayed the messagebox.
    Dave

    Helpful information I've found here so far : The Definitive "Passing Data Between Forms" : Restrict TextBox to only certain characters, numeric or symbolic :
    .NET Regex Syntax (scripting) : .NET Regex Language Element : .NET Regex Class : Regular-Expressions.info
    Stuff I've learned here so far : Bing and Google are your friend. Trying to help others solve their problems is a great learning experience

  5. #5
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: nullify {tab} key action

    The e.Handled = True line says that the actions to be carried out by this keypress have been done and that the default action doesn't get run. So if you didn't add that line then your code would run and then the default tab action would be carried out.
    You can find out more about it here.

  6. #6

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008
    Location
    india/Hubli
    Posts
    2,208

    Wink Re: nullify {tab} key action

    thanks for reply & good material

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width