Typically, this is done by using a boolean field in the form which is
called, for example, "Dirty." It is initialized to false. In your case, you
might also want to use a Property, so that when you set the value, it can
change the state of the Save button at the same time. Example:
private bool _Dirty = false;
public bool Dirty
{
get { return _Dirty; }
set { btnSave.Enabled =_Dirty = value; }
}
Then you use an event handler for each Control that can affect the Dirty
value. How this is done depends on the Control. For a combobox, the
SelectedIndexCh anged event will do the trick. For a TextBox, the TextChanged
event will work. And so on. The handlers for these events should set the
Dirty property to true. The only time the Dirty property is set to false is
when the Form is initialized.
--
HTH,
Kevin Spencer
Microsoft MVP
Chicken Salad Surgery
Who is Mighty Abbott? A twin-turret scalawag.
"Rick Shaw" <ri************ *****@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi, can anyone help? I am fairly new to C# and need help with a
functionlity in my app. What I need to accomplish is to be able to enable
the SAVE button as soon as the user modifies a data in the form. Data
could be in a datagridview or textbox. All data are connected to the
tables/dataset. What is the easiest way to do this?
Thank you.