To set focus on a form I had to P/Invoke to get it to work properly. Try
this code:
[DllImport("coredll",EntryPoint="FindWindow")]
public static extern IntPtr FindWindow(string lpClassName,string
lpWindowName);
[DllImport("coredll",EntryPoint="SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
IntPtr hWnd = FindWindow(null,form1.Text);
if(!hWnd.Equals(IntPtr.Zero))
SetForegroundWindow(hWnd);
HTH
Mark Arteaga
www.clearknowledge.com
"Anders Thomsen" <(E-Mail Removed)> wrote in message
news:u6$(E-Mail Removed)...
> Actually, it's not form2 who creates form1, but some underlying handlers.
> The form1 IS there, as it is focused when I minimize the filemanager.
>
>
>
> "Jan Yeh" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Hi, there
> >
> > I am wondering when you click the button on form2, it closes form2
itself
> > AND
> > create a new instance of form1, is that right?
> > If correct, the the sequence of statement is important, for example:
> > <in form2 instance>
> > this.Close(); // When it close, who will keep the reference of frm?
> > form1 frm=new form1();
> > frm.Show();
> >
> > Another exampler:
> > <in form2 instance>
> > form1 frm=new form1();
> > frm.Show();
> > this.Close(); // When it close, it dispose everything in form2,
> including
> > frm.
> >
> > The result of above will cause frm instance disappear, as you've seen.
>
>
>