]Is that possible to highlight the row when the cell value is change ? Can anyone teach me and explain to me ?
Thanks

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

        Dim update As New dboperation
        Dim t As DataGridViewSelectedRowCollection = Me.DataGridView1.SelectedRows
               
        update.makeconnection()

        
        If (Me.DataGridView1.Rows(t(0).Index).Cells(0).Value.ToString) = "" Then
            update.save("INSERT INTO tbuser (uname, upass, fullname, ustatus) VALUES ('" & DataGridView1.Rows(selectedrow).Cells(1).Value & "','" & DataGridView1.Rows(selectedrow).Cells(2).Value & "','" & DataGridView1.Rows(selectedrow).Cells(3).Value & "'," & DataGridView1.Rows(selectedrow).Cells(4).Value & ")")
        Else
            update.save("UPDATE tbuser SET uname='" & DataGridView1.Rows(selectedrow).Cells(1).Value & "',upass= '" & DataGridView1.Rows(selectedrow).Cells(2).Value & "',fullname= '" & DataGridView1.Rows(selectedrow).Cells(3).Value & "',ustatus= '" & DataGridView1.Rows(selectedrow).Cells(4).Value & "' WHERE uid= " & DataGridView1.Rows(selectedrow).Cells(0).Value & "")
        End If

        update.closeconnection()
        update = Nothing
    End Sub

Recommended Answers

All 2 Replies

Maybe this is something you look for:

Public Class Form1

	Private DefaultStyle As DataGridViewCellStyle

	Private Sub DataGridView1_CurrentCellDirtyStateChanged(sender As Object, e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
		If DataGridView1.IsCurrentRowDirty Then
			DataGridView1.CurrentRow.DefaultCellStyle = New DataGridViewCellStyle With {.BackColor = Color.Red, .ForeColor = Color.White}
		Else
			DataGridView1.CurrentRow.DefaultCellStyle = DefaultStyle
		End If
	End Sub

	Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
		DefaultStyle = New DataGridViewCellStyle With {.BackColor = Color.White, .ForeColor = Color.Black}
	End Sub

End Class

Thank GeekByChoiCe
I have solve my problem..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.