hi,

I am new to winForm development. When I am using the .NET 2.0 MDI Forms,
I want to close one of the child form at the very begining. For example, I
want to close Form1, so I write

public Form1() {this.close();}

And in the MID Parent, I write

form1 = new Form1();
form1.MdiParent = this;
form1.Show();

The problem is that everytime I open Form1, it will close but there will be
an object dispose exception unhandled and my program will hang up. Could
anyone here please tell me how to solve this problem? I just want to close
one of my child form. Thanks a lot!

Re: MDI Form question by VJ

VJ
Thu May 11 09:47:43 CDT 2006

you are closing a Form in it's constructor?.. that is a no-no... or did I
understand it wrong. Can you give a little bit more outline of code for your
problem..

Vijay

"jimmy" <jimmy@discussions.microsoft.com> wrote in message
news:B8B1F6BB-6520-40C8-AF33-9EF90C3356B3@microsoft.com...
> hi,
>
> I am new to winForm development. When I am using the .NET 2.0 MDI
> Forms,
> I want to close one of the child form at the very begining. For example, I
> want to close Form1, so I write
>
> public Form1() {this.close();}
>
> And in the MID Parent, I write
>
> form1 = new Form1();
> form1.MdiParent = this;
> form1.Show();
>
> The problem is that everytime I open Form1, it will close but there will
> be
> an object dispose exception unhandled and my program will hang up. Could
> anyone here please tell me how to solve this problem? I just want to close
> one of my child form. Thanks a lot!



Re: MDI Form question by jimmy

jimmy
Thu May 11 19:59:01 CDT 2006



"VJ" wrote:

> you are closing a Form in it's constructor?.. that is a no-no... or did I
> understand it wrong. Can you give a little bit more outline of code for your
> problem..
>
> Vijay
>
hi, Vijay

Thanks. And what I intend to do is to close a window at the very begining
after a IF clause. I put it in the Form1_load() function, but it does not
work. So I have to put it in the Form1 constructor, and the problem happens.



Re: MDI Form question by Robbe

Robbe
Thu May 11 20:50:50 CDT 2006

Why do you need to the load the form, run a method, and then
close the form?

Seems as if you should either make the method public on
the form and "not" call the .Show() method "or" put
the method call you are making in an entirely different
class and stop screwing with methods on a form you
don't plan to actually have a user use.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp





"jimmy" <jimmy@discussions.microsoft.com> wrote in message
news:B8B1F6BB-6520-40C8-AF33-9EF90C3356B3@microsoft.com...
> hi,
>
> I am new to winForm development. When I am using the .NET 2.0 MDI
> Forms,
> I want to close one of the child form at the very begining. For example, I
> want to close Form1, so I write
>
> public Form1() {this.close();}
>
> And in the MID Parent, I write
>
> form1 = new Form1();
> form1.MdiParent = this;
> form1.Show();
>
> The problem is that everytime I open Form1, it will close but there will
> be
> an object dispose exception unhandled and my program will hang up. Could
> anyone here please tell me how to solve this problem? I just want to close
> one of my child form. Thanks a lot!