User Id :    Password :      New Member   Forgot Password  
 
DatagridView on which Enter key works as Tab
Description Custom DatagridView on which Enter key works as Tab   No. of Views     3339
  Rating     0
Author Ankur Gupta   Posted On     13 Jul 2010
Tags ASP.NET    

Sample Code   Download Code

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.

About Author

About Author I am Ankur Gupta Working in MNC as a sr. software engg. My major area of experiance in Accounting and CRM with C#,VB.Net,WCF,ASP.net languages. Ankur
No Photo
 
Country N/A
Company PILTD
Home Page N/A

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code