Dirty value of datagridview cell

M

Morten Snedker

How do I the value of a cell in a datagridview, before it is updated?

I wish to validate the "visible" value, not the actual value (cell/row
hasn't been updated yet).


Thanks in advance.

/Snedker
 
K

Ken Tucker [MVP]

Hi,

Use the cell validating event

Private Sub DataGridView1_CellValidating(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles
DataGridView1.CellValidating
Dim strOld As String = DataGridView1.Item(e.ColumnIndex,
e.RowIndex).Value.ToString
Dim strNew As String = e.FormattedValue.ToString

Trace.WriteLine(String.Format("Old Value {0} {1}New Value {2}",
strOld, ControlChars.NewLine, strNew))
End Sub

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top