Click here to Skip to main content
11,438,797 members (74,891 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 3:19am
Code-Hunt7.1K
Comments
Sergey Alexandrovich Kryukov at 26-Dec-12 19:08pm
   
What is "reagrding"? Not clear what do you want to achieve.
—SA
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 datagrid..correct..so 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
good
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
          SendKeys.Send("{TAB}")
      End If
End Sub

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

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



Advertise | Privacy | Mobile
Web01 | 2.8.150506.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