Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A lot will depending on where the information is held.</p> <p>It you are using DataBinding you should be just monitoring the listChanged event or calling dataTable.GetChanges() if you are using a DataTable.</p> <p>If the information comes from a class the implements ICloneable and IComparable, then you can take just take a backup copy when intialising the form (and after saving) and when closing you prepare you class for saving and compare it with the original.</p> <p>Otherwise you can do something like</p> <p>Declare a private variable</p> <pre><code> private bool requiresSaving =false; </code></pre> <p>Declare an event</p> <pre><code> private void SomethingChanged(object sender, EventArgs e) { requiresSaving = true; } </code></pre> <p>Hook up this event to the various changed events, eg</p> <pre><code> this.txtNameDepart.TextChanged += new System.EventHandler(this.SomethingChanged); </code></pre> <p>(The actual event is sometimes called something different , eg ValueChanged, SelectedIndexChanged , but they can all point to SomethingChanged unless you need a particular event to do something else.)</p> <p>Check this variable when you are closing the form</p> <pre><code>private void DepartamentEdit_FormClosing(object sender, FormClosingEventArgs e) { if (requiresSaving) { .... </code></pre> <p>You also need to set requiresSaving false in the saveDepart method.</p> <p>Alternatively I have seem code where, when the control is being intialised, the tag value is also set, and the formclosing event loops through each control and compares the original values (in the tag object) with the current values.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload