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(); } }
转 : https://www.cnblogs.com/erph/p/13563595.html