Assuming you mean the OK button, you can handle the Form.Closing event which
is called just before the form itself is closed (or the Closed event which
is called after the form has been closed). If you use Closing you can
override the form from closing if some criteria is not met. Here is a simple
example where the parent form displays a message box when the other form is
closed.
private void button4_Click(object sender, System.EventArgs e)
{
//create new instance of our form
Form2 frm2 = new Form2();
//register an event handler for the Closing event of sub-form
frm2.Closing+=new System.ComponentModel.CancelEventHandler(frm2_Closing);
//show the form non-modally
frm2.Show();
}
private void frm2_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//put your code here to react on the other form closing
MessageBox.Show("Second form was closed");
}
Peter
--
Peter Foot
Windows Embedded MVP
In The Hand
http://www.inthehand.com
Handheld Interactive Reference Guides