H
Hank
Hi,
I am catching the CellValidating event in the DataGridView cell, if
validating fails, I want put focus back to the cell, following is my code(it
doens't work)
private void dataGridView_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
try
{
// code to validate
................
}
catch(Exception)
{
// if caught exception, will set the focus back
dataGridView.SelectedCells[0].DataGridView.EditingControl.Focus();
}
}
I hit the tab or clicking to another cell, my debug code goes to the
validating, however after calling the DatGridView.EditingControl.Focus(), it
still leaves the selected cell?
Please advise how can I set the focus back to the selected cell?
Thanks!
Hank
I am catching the CellValidating event in the DataGridView cell, if
validating fails, I want put focus back to the cell, following is my code(it
doens't work)
private void dataGridView_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
try
{
// code to validate
................
}
catch(Exception)
{
// if caught exception, will set the focus back
dataGridView.SelectedCells[0].DataGridView.EditingControl.Focus();
}
}
I hit the tab or clicking to another cell, my debug code goes to the
validating, however after calling the DatGridView.EditingControl.Focus(), it
still leaves the selected cell?
Please advise how can I set the focus back to the selected cell?
Thanks!
Hank