[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 523
  • Last Modified:

How do I make ENTER key work as TAB key

How do I make ENTER key work as a TAB key in DATAGRID windows form C#, MS Visual Studio 2005. I am able to make this happen in Windows Form without DATAGRID but when I use the same logic in DATAGRID then it is not working. In other words I want to move the cursor to the next cell when user press the ENTER key(want to move horizontally), Right now when user press the ENTER key it move to the down (moving vertically).
0
heemandalal
Asked:
heemandalal
1 Solution
 
pony10usCommented:
Another good one shows the actual C# code you are wanting even though the request is to have it converted to VB.

http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/34a92656-8325-4085-bc9f-663b62cb9b5d/
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello, you can try this two methods:

If your DataGridView has StandardTab = false, by using the DataGridView KeyDown event:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        e.Handled = true;
        SendKeys.SendWait("{tab}");
    }
}

Open in new window


If your DataGridView has StandardTab = true, by using the DataGridView KeyDown event:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        e.Handled = true;
        SendKeys.SendWait("{RIGHT}");
    }
}

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now