All,I knew we can set a column editable for a DataGridView
.
And when finish editing the cell. the CellEndEdit
event would be triggered.
But I just want
Try using the HitTest function in the MouseDown event of the grid:
void dgvFileList_MouseDown(object sender, MouseEventArgs e) {
DataGridView.HitTestInfo hit = dgvFileList.HitTest(e.X, e.Y);
if (hit.RowIndex < 0 | hit.ColumnIndex < 0) {
dgvFileList.EndEdit();
}
}
Clicking outside the DataGridView control would require hitting a focusable control.