How to run Run CellEndEdit only when Cell ValueChanged in DataGridView

后端 未结 5 1279
囚心锁ツ
囚心锁ツ 2021-01-13 04:45

i want to run CellEndEdit only when value of cell is changed, tried putting

if (dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == e.For         


        
5条回答
  •  时光说笑
    2021-01-13 05:14

    But if you want to compute the value edited, you can use the suggested issue by J.Fisher like:

    Private Sub dgvHost_CellBeginEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvHost.CellBeginEdit
        dgvHost.CurrentCell.Tag = dgvHost.CurrentCell.Value
    End Sub
    
    Private Sub dgvHost_CellEndEdit(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvHost.CellEndEdit
        If dgvHost.CurrentCell.Tag = dgvHost.CurrentCell.Value Then Exit Sub
        dgvHost.CurrentCell.Tag = Nothing
        'Do something like
        dgvHost.CurrentCell.Value = MD5(dgvHost.CurrentCell.Value)
    End Sub
    

提交回复
热议问题