DATAGRIDVIEW 禁止单元格焦点转移

当datagridview单元格内容改变后,点击回车键,禁止单元格焦点转移

 

public bool isNext = false; private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DialogResult dr=MessageBox.Show("确定要改变吗?","",MessageBoxButtons.OKCancel); isNext = false; if (dr!=DialogResult.OK) { isNext = true; } } private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e) { if (isNext) { e.Cancel = true; } }

你可能感兴趣的:(object)