Click here to Skip to main content
11,813,379 members (72,688 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB Windows VB.NET
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 at 26-Dec-12 19:08pm
What is "reagrding"? Not clear what do you want to achieve.
Snehasish Nandy at 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
0 Abhinav S 270
1 CHill60 180
2 KrunalRohit 154
3 Palash Mondal_ 145
4 Sergey Alexandrovich Kryukov 140
0 OriginalGriff 3,877
1 KrunalRohit 2,496
2 CPallini 2,240
3 Maciej Los 2,205
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 3 Jan 2013
Copyright © CodeProject, 1999-2015
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