How can I retrieve the previous value of a DataGridView cell using the CellValueChanged event?

HOUSSEM MAHJOUBI 286 Reputation points

Hi members
i have a datagridview which i make (insert/update into db)
if the cell in datagridview is null its an insert simple but
if it has a value its an update( to make the update i want get that value in the cell and use it for the update after )
how i can retrieve that value ?
i use CellValueChanged event for validating
i have the idea to use :
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
newvalue = (int)dataGridView1[e.ColumnIndex, e.RowIndex].Value;

private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
oldvalue = (int)dataGridView1[e.ColumnIndex, e.RowIndex].Value;
but i have no idea how to store the old value in CellBeginEdit to use it in CellEndEdit after
please help

1 vote