Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need write code for go next line when click enter on column Address

I have a data gridview with 4 columns: ID,Name,Address,Amount

I need when click enter key on any cell on column Address go to next line after press enter key .

I using this datagridview to get data from database based on datatable so that datagridview i used for search only .

So actually i need when access column Address and press enter go to next line .
based on rows exist on datagridview .

i dont need to add rows to gridview only i need to go to next line when press enter key on column Address.

What I have tried:

.
Posted
Updated 3-Mar-18 20:47pm
v2

1 solution

You have several options, personally I would go for the CellValueChanged event:
private void myDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
    MessageBox.Show("The value was changed, row = " + e.RowIndex);
    myDataGridView.CurrentCell = myDataGridView[e.ColumnIndex, e.RowIndex + 1];
}
Another options is the KeyDown event: c# - How to move focus on next cell in a datagridview on Enter key press event - Stack Overflow[^]
 
Share this answer
 
v2
Comments
Maciej Los 4-Mar-18 12:20pm    
5ed!
RickZeeland 4-Mar-18 12:22pm    
Thanks :)

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