Click here to Skip to main content
13,457,690 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

i have one datagrid and i want like when i click on any cell and press enter key, then the control should go to the next cell.
by default it is going to the next row.
and when i press tab it's going to the next cell.

So i want that tab function in enter key

Please tell me how to do..

Thank you
Posted 26-Dec-12 2:19am
Sergey Alexandrovich Kryukov 26-Dec-12 19:08pm
What is "reagrding"? Not clear what do you want to achieve.
Snehasish Nandy 27-Dec-12 0:13am
I want is by default we have to press tab to go to the next cell of the i want that function in enter button..if we press enter key then it should go to the next cell

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your question is quite confusing but I assume you want your gridview to move the cursor/focus to the next cell after pressing the "enter" key instead of going to the next row (in other words, do what the "tab" key).

If that is the case then for me the easiest way to do that is to trap the key in KeyDown event and send the key that you need to be pressed

Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown     
      If e.KeyCode = Keys.Enter Then
          e.SuppressKeyPress = True
      End If
End Sub

This might interfere with other things you need to do but can be adjusted accordingly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01-2016 | 2.8.180322.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100