Hi mwindham,
I guess the DataValidating you mentioned refers to the CellValidating event of the DataGridView control. If you want to prevent DataGridView’s focus from leaving the current cell in the CellValidating event, you can simply do this:
void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.FormattedValue != 10)
{
e.Cancel = true;
}
}
Otherwise, there are three ways that cause the CurrentCell to change after the CellValidating event. They are: pressing the Enter key, pressing the Tab key and clicking the left button of the mouse when a cell is being edited.
You need to derive the DataGridView class and override the ProcessDialogKey, ProcessDataGridViewKey and WndProc methods to handle the above three situations respectively.
Please have a look at this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3077957&SiteID=1
Regards,
Jacob