Click here to Skip to main content
16,018,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Members

i have a Data Gridview,i want to move when i press Enter Button my cursor only those cell whose read only properties is false.and when cursor reach last cell it move to next row in which cell whose read only properties is false.

i try many of properties of gridview but these properties are not working.

Please Help me

Member of Code Project

Akhilesh Pandit
Posted
Comments
Richard C Bishop 15-Aug-13 15:38pm    
You will need to post your code so that we can tell you.

1 solution

Try with this code :
C#
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {                
                e.SuppressKeyPress=true;
                int iColumn = dataGridView1.CurrentCell.ColumnIndex;
                int iRow = dataGridView1.CurrentCell.RowIndex;
                if (iColumn == dataGridView1.Columns.Count-1)
                    dataGridView1.CurrentCell = dataGridView1[0, iRow + 1];
                else
                    dataGridView1.CurrentCell = dataGridView1[iColumn + 1, iRow];

            }
        }

Also can view..
Set focus to next cell when pressing enter key in datagridview control[^]
Set focus to next cell when pressing enter key in datagridview control?[^]
DataGridView-when I press enter it goes to the next cell[^]
 
Share this answer
 
v3

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