locked
event associated to pressing enter (on the keyboard) while I m selecting a row in datagrid RRS feed

  • Question

  • I wonder about 2 things:

    1/ How do I force in the code the cursor (to select or give focus) to the first row in my datagrid. when I do the method:  datagrid1.focus()   it doesn t select my datagrid it doesn t do anything.

    2/ I want to trap the event of selecting the datagrid in my form. the code bellow doesn t doesn t work:

    Datagrid1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGrid1.KeyUp

    If e.KeyData = Keys.Enter Then func2()

    and when I remove the condition If e.KeyData = Keys.Enter   The code executes for all the keys and not only for Enter key

    P.S: I don t have a problem with the mouse events, working fine, but only with the Enter key on keyboard

    Thanks Folks.

    Wednesday, February 8, 2006 5:15 PM

Answers

All replies

  • try using keys.Return instaed of enter..

     

    HTH

    Wednesday, February 8, 2006 5:33 PM
  • You should try to use Select instead of Focus. Check this previous post. Let me know if this solves your problem.
    Wednesday, February 8, 2006 5:55 PM
  • Hi dear Van der Beek, works perfectly and resolvs my fist issue, u re the man.

    my other pb for traping the Return key pressing event while datagrid s focus still not working, My datagrid doesn t trap the event of hitting return key.

    Thanks guys

     

    Wednesday, February 8, 2006 6:07 PM