I'm trying to edit the value of a Celda
of DataGridView
after the event CellEndEdit
by pressing the% key Enter
send by code a TAB
I'm currently using the Event KeyPress
and the EditingControlShowing
of the Datagridview but it has not worked.
EditingControlShowing:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox textbox = e.Control as TextBox;
if (textbox != null)
{
textbox.KeyPress -= new KeyPressEventHandler(dataGridView1_KeyPress);
textbox.KeyPress += new KeyPressEventHandler(dataGridView1_KeyPress);
}
}
KeyPress Event:
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13) // Si es un enter
{
e.Handled = true; //Interceptamos la pulsación
SendKeys.Send("{TAB}"); //Pulsamos la tecla Tabulador por código
}
}
I've also tried the KeyDown Event:
if (e.KeyCode.Equals(Keys.Enter))
SendKeys.Send("{TAB}");
It does not work! Any ideas on how to achieve it?
I found this answer from OS , but it does not work correctly.
Environment: Visual Studio 2010 & .NET Netframework 4