Я получил решение Geetha, я обработал событие EditingControlShowing для моего DataGridView.Код ниже:
private void Lot_dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control is DataGridViewTextBoxEditingControl)
{
if (ColIndex == "2") // this colIndex i got it from CellEnter event.
{
DataGridViewTextBoxEditingControl te = (DataGridViewTextBoxEditingControl)e.Control;
te.TextChanged += new EventHandler(textbox_TextChanged);
}
}
}
, а затем я обработал событие textbox_TextChanged.
void textbox_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
MessageBox.Show(tb.Text);
// Do your changes here.
// To Change focus from the current cell use
SendKeys.Send("{TAB}"); // to give focus to next cell in the same row.
}