best practice for data changed check

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

I'm supposed to prompt the user to save changes when
switching tabs or closing a form if the user has made any
changes. I'm curious as to a best practice or
recommended solution for checking if changes have
occurred on a form with lots of fields.

Options:
1. I'm currently not performing any databinding, so
DataSet.GetChanges I don't think is for me.
2. I could attach OnChange events to all of my form
fields, but that is a pain with DateTimePicker controls.
3. Check each form field value against the initial value
when exiting.

I'm leaning toward #3. Are there any elegant solutions
I'm not thinking of?

Thanks in advance,
Frank
 
I'm supposed to prompt the user to save changes when
switching tabs or closing a form if the user has made any
changes. I'm curious as to a best practice or
recommended solution for checking if changes have
occurred on a form with lots of fields.

Options:
1. I'm currently not performing any databinding, so
DataSet.GetChanges I don't think is for me.
2. I could attach OnChange events to all of my form
fields, but that is a pain with DateTimePicker controls.
3. Check each form field value against the initial value
when exiting.

I'm leaning toward #3. Are there any elegant solutions
I'm not thinking of?

Thanks in advance,
Frank

Frank

What about solution2 but point all the change events to one
function, i.e.

private void JDataChanged()
{
blnDirty = true;
}

Then you only have one data changed function and you only have
to check the state of blnDirty on exiting.

I'd be interested in other views as well since this has always
puzzled me too :-)
 
Back
Top