Hello, i have a problem relatrive to DataRowState.Unchanged, i have
the bellow code in my Save Button calling BSModificada()
'IF ANY CHANGE SaveData()
Private Sub BSModificada()
Me.Validate()
Me.TABMAINBindingSource.EndEdit()
Dim vDR As DataRow =3D CType(Me.TABMAINBindingSource.Current,
DataRowView).Row
If vDR.RowState <> DataRowState.Unchanged Then
SaveData()
End If
End Sub
'IF Added or Modifyed Update
Private Sub SaveData()
Try
Dim vvDR As DataRow =3D
CType(Me.TABMAINBindingSource.Current, DataRowView).Row
If vvDR.RowState =3D DataRowState.Detached Then
DBAdiciona()
ElseIf vvDR.RowState =3D DataRowState.Modified Then
DBModifica()
End If
Catch ex As Exception
clsUtilidades.ShowError(ex.Message, ex.ToString)
End Try
End Sub
In DBAdiciona() and DBModifica() i am always Accepting Changes by
Me.ESTDataSet.TAB_MAIN.AcceptChanges().
This code works good, until i try to see if any Change made when
closing the form, i am always prompted to save when any Row is
Modified even i click the save button and Accepting the Dataset
Changes, the code bellow on Form Closing
Private Sub frmEstatisticaMensal_FormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
Me.Validate()
Me.TABMAINBindingSource.EndEdit()
Dim vvvDR As DataRow =3D CType(Me.TABMAINBindingSource.Current,
DataRowView).Row
If vvvDR.RowState <> DataRowState.Unchanged Then
If MessageBox.Show("Altera=E7=F5es detectadas, quer gravar?",
"", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =3D
Windows.Forms.DialogResult.Yes Then
e.Cancel =3D True
SaveData()
Else
e.Cancel =3D False
End If
End If
End Sub
Thanks for your time, any help will be welcome
Joao