954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Detect data change in datagrig

I am using Vb.net 2003 and would like some method for detecting when user has made any change to any data in a datagrid.

I have a simple Windows form with a single datagrid with four columns. The first column is locked to prevent user from modifying it. All the other fields can be edited. The form only has two buttons: Ok and Cancel.

What I want to do is have the Ok button be disabled until some change is made to the data in the datagrid.

I have been trying to use the following code which is not working:

Private Sub HomeInfo_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HomeInfo.CurrentCellChanged
Me.btnOk.Enabled = True
End Sub

I am also trying to have the application check for unsaved data if the user click the X on the form to close the form. I am attempting to use the following code in the "Closing" event of my form:

If (DataHomeIngo11.HasChanges(DataRowState.Modified)) Then
Dim response As MsgBoxResult
response = MsgBox("Do you want to save your changes?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo Or MsgBoxStyle.DefaultButton2, "Save Changes?")
If response = MsgBoxResult.Yes Then
OleDbDataAdapter1.Update(DataHomeIngo11)
End If
End If

Any assistance is appreciated.

Byron P

Byron P
Newbie Poster
4 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You