Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Enter key to jump from one datagrid to the next 1

Status
Not open for further replies.

bigmelon

MIS
Sep 25, 2003
114
US
Does anyone know how this can be done? I have looked at the IsInputKey and PreProcessKey but haven't had any luck with either one of them. I then made a new class for the datagrid as follows:

Code:
Public Class MyDataG
    Inherits System.Windows.Forms.DataGrid
    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, _
                               ByVal keyData As Keys) As Boolean
        Const WM_KEYDOWN As Integer = &H100
        Const WM_SYSKEYDOWN As Integer = &H104

        If ((msg.Msg = WM_KEYDOWN) Or (msg.Msg = WM_SYSKEYDOWN)) Then
            Select Case (keyData)
                Case Keys.Enter
                    Me.Parent.Text = "Enter Key Captured"

            End Select
        End If

        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
End Class

This changes the header text, but I can't figure out how to call the datagrid from this class. Any ideas? I'm stumped.

Thanks in advance,
Jeremy
 
To call a datagrid from it's inherited class, use the Me keyword.
 
I'm trying to call a second datagrid, not the one shown above. I'm trying to use the first datagrid to call the second. When I hit the enter key, I want it to leave the first datagrid and select a row in the second. Does that make sense to you?
 
See if the trick I mentioned the other day works. (Again found this on Experts Exchange in a VB6 forum a long time ago...don't remember who posted it.) Try a :

Code:
Me.Enabled= False
Me.Enabled = True

This should move the focus to the next control.
 
That does move the focus to the next control, but I want to select the whole row. Do you have any idea how to do that?

Thanks a lot,
Jeremy
 
I tried me.select(me.currentrowindex) and me.select(0) but they didn't do anything
 
No, I don't know how, although I've seen tips about it on the web for selecting a whole row.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top