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.
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
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Aug 3, 2022, 5:42 AM EDT
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
}
}
Amit MohantyRank #112 · 20K reputationPosted Aug 3, 2022, 5:54 AM EDT
Naresh N17 reputationPosted Aug 3, 2022, 6:06 AM EDT