Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / January 2007

Tip: Looking for answers? Try searching our database.

How to determine if a form IsDirty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Rand - 29 Jan 2007 22:12 GMT
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().
Bart Mermuys - 31 Jan 2007 19:20 GMT
Hi,

> 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
[quoted text clipped - 4 lines]
> Other than catching the text control's EditValueChanged event, is there a
> simpler way that applies to the whole form?

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

> It would be nice if the binding source had a IsDirty property that is set
> to true prior to the EndEdit().
Jim Rand - 31 Jan 2007 20:49 GMT
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

> Hi,
>
[quoted text clipped - 19 lines]
>> It would be nice if the binding source had a IsDirty property that is set
>> to true prior to the EndEdit().

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.