MDI Form question


G

Guest

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!
 
Ad

Advertisements

V

VJ

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
 
G

Guest

VJ said:
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.
 
Ad

Advertisements

R

Robbe Morris [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top