c# datagridview在编辑时触发事件,获取输入值
datagridview在设计时,需要在单元格编辑时触发相关事件获取数据
private void dgv_CurrentCellDirtyStateChanged(object sender, EventArgs e) { if (dgv.IsCurrentCellDirty) { dgv.CurrentCellDirtyStateChanged -= dgv_CurrentCellDirtyStateChanged; dgv.CommitEdit(DataGridViewDataErrorContexts.Commit); dgv.CurrentCellDirtyStateChanged += dgv_CurrentCellDirtyStateChanged; int c = dgv.CurrentCellAddress.X; int r = dgv.CurrentCellAddress.Y; label1.Text = dgv.CurrentCell.Value.ToString(); } }