Solved

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

Posted on 2003-11-21
5
834 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
ID: 9802829
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9805646
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
ID: 11669856
My recommandation: points to emoreau (the comment from TheAvenger is very near to the code of link I did provide).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 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

12 Experts available now in Live!

Get 1:1 Help Now