Hai expert..................
please help me......
How to move to next cell in DataGridView by Pressing Enter
Thanks in advance
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nir Bar107 reputationPosted Sep 30, 2009, 12:04 AM EDT
You should create an event handler for the KeyUp event.
Pseudo-code should be:
Please mark this post as an answer if it helps you
Nir
Soumya Surendran84 reputationPosted Sep 30, 2009, 11:38 PM EDT
Nagesh R14 reputationPosted Oct 1, 2009, 2:29 AM EDT
Soumya Surendran84 reputationPosted Oct 2, 2009, 2:10 AM EDT
salman khan2 reputationPosted Aug 10, 2012, 12:15 PM EDT
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.ColumnCount - 1 == e.ColumnIndex) //if last column
{
KeyEventArgs forKeyDown = new KeyEventArgs(Keys.Enter);
notlastColumn = false;
dataGridView1_KeyDown(dataGridView1, forKeyDown);
}
else
{
SendKeys.Send("{up}");
SendKeys.Send("{right}");
}
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && notlastColumn) //if not last column move to nex
{
SendKeys.Send("{up}");
SendKeys.Send("{right}");
}
else if (e.KeyCode == Keys.Enter)
{
SendKeys.Send("{home}");//go to first column
notlastColumn = true;
}
}
sushil kardhone2 reputationPosted Apr 29, 2016, 11:31 PM EDT
Abdul Amin KhanRank #2,247 · 627 reputationPosted Sep 4, 2018, 8:06 PM EDT