ARTICLE

DatagridView on which Enter key works as Tab

Posted by Ankur Gupta Articles | Active Directory in VB.NET June 02, 2010
Custom DatagridView on which Enter key works as Tab
Download Files:
 
Reader Level:

Most of the user use Enter key except Tab to move focus in the next controls because it is very faster to press Enter key instead of Tab key.

But in .net the DataGridView works with Tab key to move focus in Next cell so we need to customize the datagridView and Overrides some function.

Add a new custom control in project and inherits it with System.Windows.Forms.DataGridView.

First Override ProcessDataGridViewKey function and write the following code.

Protected Overrides Function ProcessDataGridViewKey(ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean

        If e.KeyCode = System.Windows.Forms.Keys.Enter Then

            Me.ProcessTabKey(e.KeyData)

            Return True

        End If

        Return MyBase.ProcessDataGridViewKey(e)

    End Function

 

Then Override ProcessDialogKey function as fillowes

Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean

        If keyData = System.Windows.Forms.Keys.Enter Then

            Me.ProcessTabKey(keyData)

            Return True

        End If

        Return MyBase.ProcessDialogKey(keyData)

    End Function

 

After that Build the application then you will find that there in a new control in your toolbox named as your custom control name.

You can easily use this with drag and drop and in this datagridview enter key works as a tab key.

Login to add your contents and source code to this article
share this article :
post comment
 

thank you so much

Posted by jo orn Apr 01, 2011

Hi Ankur Gupta really helpful to me ur datagridview article thank u very much.

Posted by Athi Narayanan Jul 15, 2010
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Become a Sponsor