When datagridview is in edit mode keydown event not fairing any help
Loading
When datagridview is in edit mode keydown event not fairing any help
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajanikant HawaldarPosted Aug 3, 2022, 9:42 AM
Grid level not then try form level, In EditingControlShowing event you should subscribe keydown / keypress etc. Check below code it will work.
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is DataGridViewTextBoxEditingControl tb)
{
tb.KeyDown -= dataGridView1_KeyDown;
tb.KeyDown += dataGridView1_KeyDown;
}
}
//then in your keydown event handler, execute your code
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Alt | Keys.S))
{
//save data
}
}
Naresh NPosted Aug 3, 2022, 10:06 AM
Amit MohantyPosted Aug 3, 2022, 9:54 AM