> Handle form_Closing event in second form. You can pass the first form to
> second form in its constructor.
[quoted text clipped - 17 lines]
> >
> > Mark
feel free to butt away ...
Ajay's suggestions worked just fine, although i still don't get why my
original Activated and Enter events didn't do the job.
I'm winging this in pseudo code, but in form2, you'd need to change it to be
something like ...
public class Form2
{
private Form1 _frm;
public Form2(Form1 frm)
{
_frm = frm; //Sets a reference to the form1 instance;
}
public void CloseSomethingOrOtherEvent()
{
//Note that this does NOT create a new instance of the form, but uses
the existing reference held in _frm.
_frm.SomePublicMethodOnForm1ThatRefreshesDataGrid();
}
}
***** AND THEN *****
1. In form1 you'd do something like:
> Form2 myForm2 = new Form2( this );
> myForm2.Show();
HTH.
Mark
www.dovetaildatabases.com
> Pardon me for butting in, but how would you do this?
>
[quoted text clipped - 48 lines]
> > >
> > > Mark
Bjarke Lindberg - 14 Dec 2004 12:06 GMT
> feel free to butt away ...
Thanks ;)
> public Form2(Form1 frm)
> {
> _frm = frm; //Sets a reference to the form1 instance;
> }
Well - this way Form2 is dependant on Form1.
Wouldn't it be 'cleaner' if you let Form1 handle the Form2's
CloseSomethingOrOtherEvent?
> 1. In form1 you'd do something like:
>
> > Form2 myForm2 = new Form2( this );
> > myForm2.Show();
Or:
Form2 myForm2 = new Form2();
myForm2.CloseSomethingOrOtherEvent
+= new EventHandler(this.HandleForm2Close);
myForm2.Show();
/B