Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > DataGrid View
 

DataGrid View

Hi how to make enter key behave like a tabkey in datagrid view, using vb.net windows application?

Thanks in advance..!
j.nanda27  Tuesday, September 29, 2009 12:56 PM

Hi,

 

When DateGridView is in edit mode, enter Key is processed in ProcessDialogKey() method. When DataGridView is not in edit mode, we can override ProcessDataGridViewKey() to change the navigation.

There is a FAQ tells about this:

9. How can I make the Enter key work as Tab key?

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e#faq9

 

And the following is VB.NET code:

Public Class MyDataGridView

    Inherits DataGridView

 

    Protected Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean

        If e.KeyCode = Keys.Enter Then

            Me.ProcessTabKey(e.KeyData)

            Return True

        End If

        Return MyBase.ProcessDataGridViewKey(e)

    End Function

 

    Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean

        If keyData = Keys.Enter Then

            Me.ProcessTabKey(keyData)

            Return True

        End If

        Return MyBase.ProcessDialogKey(keyData)

    End Function

 

End Class

 

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, October 05, 2009 7:42 AM

Hi,

 

When DateGridView is in edit mode, enter Key is processed in ProcessDialogKey() method. When DataGridView is not in edit mode, we can override ProcessDataGridViewKey() to change the navigation.

There is a FAQ tells about this:

9. How can I make the Enter key work as Tab key?

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e#faq9

 

And the following is VB.NET code:

Public Class MyDataGridView

    Inherits DataGridView

 

    Protected Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean

        If e.KeyCode = Keys.Enter Then

            Me.ProcessTabKey(e.KeyData)

            Return True

        End If

        Return MyBase.ProcessDataGridViewKey(e)

    End Function

 

    Protected Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean

        If keyData = Keys.Enter Then

            Me.ProcessTabKey(keyData)

            Return True

        End If

        Return MyBase.ProcessDialogKey(keyData)

    End Function

 

End Class

 

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, October 05, 2009 7:42 AM

You can use google to search for other answers

Custom Search

More Threads

• IssueVision for VS2005/.NET 2.0
• TaskListControl
• Changing readonly property of all textboxes on form
• Terrarium 1.2... Are there going to be 'stones' in Terrarium?
• RAR
• Offline file encryption
• "Terrarium Server Is Experiencing Difficulties" error...
• where to start?
• Is it dead?
• Do you think which one is the best iPhone to PC Transfer help you transfer iPhone files to PC?