Bound Form Dirty
In VS2005 b2 I have a bound windows form. How do I determine if the user has made changes to the data?
TIA
I am amazed that such a common need as determining if any changes have been made to bound data is not supported in a simple boolean somewhere.
How do I check the 'version' property (there does not appear to be a 'version' property on any of may objects that is of use) of a row?
My form does use a dataset and can have one or more rows. VS2005 B2 VB is the platform. The dataset is connected to SQL Server 2000.
I have tried using Me.MyTableBindingSource.Current to get a DataRowView of the displayed row. This object does not have a DataRowState which would be useful. It does have a DataRowVersion but it always seems to return 'Current' as the value when I check the Local value.
I am trying to write a function like this: Function
DirtyRow = (row.RowVersion <> Data.DataRowVersion.Original)
End Function Called by:If DirtyRow(
Me.MyTableBindingSource.Current) Then...
Note this call uses the binding source and not the DataSet. I don't see a way to get a row from the dataset that corresponds to the displayed data.
Do I have to resort to monitoring keystrokes to set my own dirty flag? Sad.
Txghia58 wrote:
Is it bound to a dataset? If so you could check the version property of the row in the dataset.
Could someone give an example of how to do this assuming the form is bound to a dataset created by dragging a table from the Data Sources pane in the IDE?
TIA
I dont know if you ever got an answer but here is my sample
Sub chk()
Dim ans As Boolean = False
If Me.TestSigCapDataSet.HasChanges Then Me.Text = "HasChanges=Yes " Else Me.Text = "HasChanges=No " If CType(Me.LoginsBindingSource.Current, DataRowView).Row.HasVersion(DataRowVersion.Proposed) Thenans =
True End If Me.Text += " HasProposed=" + ans.ToStringEnd Subjerry C
What events?
This issue is exactly the issue i am trying to get an answer for in my current post at
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=696784&SiteID=1
If you have any insight i would be very happy.
Jerry Cicierega
It appears that the 'RowChanged' event only fires after the acceptchanges in invoked. This is well after any HasChanges flags have been set. And after any column data is assigned a 'proposed' version value.
I myself am looking for an event that fires as soon as the DataRow.HasVersion(DataRowVersion.Proposed) becomes true.
This occurs when any edit occurs, even before HasChanges becomes true. In order for HasChanges to become true, the EndEdit must be invoked for the current row or the CurrencyManager.Position must change.
Jerry Cicierega