Hi Friend,
I believe that you can use the method that I am gonna provide you here in VB too, since I am not working with VB and this one is in C#, so pretty off the language of your interest but perfect in the way what you require to do. I hope you will be able to translate it in VB since .NET is quite Language independent :-)
Let us look at my solution, that I am giving you here after 1 hr of mind boggling work (only for you my friend)
See, the codes first, then I will explain it below :
The first thing is to define a global boolean
bool changed = false;
The next step is to define this inside Form Load Event:
foreach (Control mycon in this.Controls.OfType<TextBox>())
{
mycon.TextChanged += new EventHandler(mycon_TextChanged);
}
As you can see here, I simply looped through all the textbox controls (well you can do for other controls also) and added a single event handler function to all of them. Now let us see what's inside this function. so here's the code :
public void mycon_TextChanged(object sender, EventArgs e)
{
changed = true;
foreach(Control mycon in this.Controls.OfType<TextBox>())
{
mycon.TextChanged -= mycon_TextChanged;
}
}
Now here I simply set that boolean to true and after that I removed all the event handlers since I guess they are no longer required as the close button now for sure will have to ask for saving the changes (Change has been made).
Now You simply need to test this boolean, and if it is set, implement your codes to save this new data :-) Cheers
Regards
Tushar Srivastava :-)