Groups | Blog | Home
all groups > dotnet windows forms databinding > january 2007 >

dotnet windows forms databinding : How to determine if a form IsDirty


Jim Rand
1/29/2007 5:12:29 PM
Let's say you have a form with a bunch of text boxes bound to a binding
source. The form also has a "Save" button which you want enabled only if
the user has made changes. The Save button will call
bindingSource.EndEdit() and will then instruct the dataset to update the
database.

Other than catching the text control's EditValueChanged event, is there a
simpler way that applies to the whole form?

It would be nice if the binding source had a IsDirty property that is set to
true prior to the EndEdit().


Jim Rand
1/31/2007 3:49:13 PM
Bart,

You have solved the problem no one else has! Great idea!

Here is how I implemented it.

private void dataNavigator_PositionChanged(...)
{
btnSave.Enabled = false;
if ( _RWAccess ) { timer.Enabled = true; }
}

private void timer_Tick(...)
{
if
(((DataRowView)bs1Office.Current).Row.HasVersion(DataRowVersion.Proposed))
{
timer.Enabled = false;
btnSave.Enabled = true;
}
}

You have saved me an incredible amount of work!

Thanks
Jim

[quoted text, click to view]

Bart Mermuys
1/31/2007 7:20:40 PM
Hi,

[quoted text, click to view]

No ,don't think so, it seems to be a missing feature.

If you are binding to ADO.NET, you could use:
((DataRowView)BindingSource.Current).Row.HasVersion(DataRowVersion.Proposed)
to check for changes, but as someone previously pointed out, there isn't an
event you can handle for this.

HTH,
Greetings



[quoted text, click to view]

AddThis Social Bookmark Button