Check if contents of DataGridView have been edited by a user
I use the following code block to visually indicate if cells on a datagridview have been edited.
May not be quite what you want, but could point you in a direction.
Code:
Private Sub dgvDimensions_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles dgvEditFlashingPrices.CellBeginEdit
preEditValue = dgvEditFlashingPrices.Item(e.ColumnIndex, e.RowIndex).Value.ToString
End Sub
Private Sub dgvDimensions_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvEditFlashingPrices.CellEndEdit
Dim today As String = (CType(Updated, Date).ToString("dd MMM yyyy"))
If ckbEditListprice.Checked = True Then
If Not preEditValue = dgvEditFlashingPrices.Item(e.ColumnIndex, e.RowIndex).Value.ToString Then
dgvEditFlashingPrices.Item(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Coral
dgvEditFlashingPrices.Rows(e.RowIndex).Cells(e.ColumnIndex + 3).Value = today
dgvEditFlashingPrices.Rows(e.RowIndex).Cells(e.ColumnIndex + 3).Style.BackColor = Color.Aqua
preEditValue = String.Empty
End If
Else
If Not preEditValue = dgvEditFlashingPrices.Item(e.ColumnIndex, e.RowIndex).Value.ToString Then
dgvEditFlashingPrices.Item(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Coral
dgvEditFlashingPrices.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value = today
dgvEditFlashingPrices.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Style.BackColor = Color.Aqua
preEditValue = String.Empty
End If
End If
End Sub
The line Color.Coral shows the edited cell. The line color.Aqua merely indicates to the user that the row will be updated when the update button is clicked.
HTH
Cheers
John
Edited by - TAILOR on 4/17/2008 2:33:26 PM
source :http://www.vbcity.com
-------------------------------------------------------
Trik Gambar Bergerak
Trik Gambar-dimouse
Trik hapus pwd mysql
Trik insertin to db
Trik jadi root dilinux
Trik jam-distatus-bar
Trik Koneksi-ke database
Trik Koneksi-msql-php
Trik lihat-database-mysql
Trik membahas-fungsi-else
Trik member-area