Byron P 0 Newbie Poster

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

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.