Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i am using data grid view in dotnet in which i want to traverse column by column through enter key it must traverse column by column not by last column suppose i have 5 columns in data grid view and started using the first column now after pressing enter key it must visit the second column not the last and if i pressed the enter key in the 3rd column in the current row and forgot to update any value in the previous colurmn of the current row or previous row i can move my cursor at the required column and after updating the value in that column i want to start traversing once again from the column to last column (column by column )by pressing enter key .
Posted
Updated 30-Oct-12 7:31am
v2
Comments
ALOK CHANDAN 30-Jan-13 1:25am    
i am using data grid view in dotnet in which i want to traverse column by column through enter key it must traverse column by column not by last column suppose i have 5 columns in data grid view and started using the first column now after pressing enter key it must visit the second column not the last and if i pressed the enter key in the 3rd column in the current row and forgot to update any value in the previous colurmn of the current row or previous row i can move my cursor at the required column and after updating the value in that column i want to start traversing once again from the column to last column (column by column )by pressing enter key .

I would strongly suggest that you reconsider.

Users generally expect ENTER to effect a button, or submit a page generally. To move from field to field, they expect to use TAB.
Unless you have a *VERY* good reason for changing this behaviour you will just confuse and annoy your users, and that means they won't use your program.
 
Share this answer
 
I would write an event handler for the Keypress event for the grid and look for the enter key. Then would manually set the focus to the next column. Don't forget to set the e.Handled = True.
 
Share this answer
 
Comments
ALOK CHANDAN 30-Oct-12 14:23pm    
i am also trying e.handled=true;
and sendkey.key(Tab);
but this is use a last row if i can press in any column of any row then my cursor is select in next row. but i want my cursor select next column.
Clifford Nelson 30-Oct-12 14:34pm    
Do not try to use the sendkey, just manually do it, use the setfocus command. I have not found the sendkey works very well.
ALOK CHANDAN 3-Mar-13 1:29am    
Please Sir define your answer i am confuse because i don't think how to work manual code in multiple row if i again write in first row then how to work
please sir urgent ans me.
 
Share this answer
 
Comments
ALOK CHANDAN 30-Oct-12 14:50pm    
this is work properly only last row not in any row of column. i want to use in any row.
ALOK CHANDAN 30-Oct-12 14:53pm    
if multi row is available in datagridview and we can edit in any row of column then this command not work properly. if single row or last row this is work good. so please suggest me how to work in any row of column using enter

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900