Solved

Send "Tab" key in datagrid when press "Enter" Key.

Posted on 2003-11-21
5
828 Views
Last Modified: 2008-02-01
hello.
Many applications that display data in a grid interface allow the user to use the ENTER (RETURN) key to navigate from cell to cell.
I want when I press Enter key the next cell of DataGrid  be selected. for first time this is done with follow code but for second time the focus go to the last cell of datagrid.


protected override bool ProcessCmdKey(ref Message msg, Keys keydata)
{

if(keydata == Keys.Enter)
{
 SendKeys.Send("{Tab}");
 return false;
}
base.ProcessCmdKey(ref msg, keydata);

}
0
Comment
Question by:mystar
  • 2
5 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 75 total points
Comment Utility
0
 
LVL 20

Expert Comment

by:TheAvenger
Comment Utility
You should change your code a little bit:

protected override bool ProcessCmdKey(ref Message msg, Keys keydata)
{

if(keydata == Keys.Enter)
{
 SendKeys.Send("{Tab}");
 return true;
}
return base.ProcessCmdKey(ref msg, keydata);

}
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
My recommandation: points to emoreau (the comment from TheAvenger is very near to the code of link I did provide).
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Email Body 4 46
network + 7 73
c# string 6 39
Round up to 100% in .NET 10 41
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now