Link to home
Start Free TrialLog in
Avatar of schenkp
schenkp

asked on

How to kill a form

HI,
If i have a couple of forms open and i would like them to close when the user clicks on a button on the main form, what the best way to do this?
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

On the main form keep a reference to the forms you wish to close then when the user clicks on the button do ReferenceToForm.Close(); Where the ReferenceToForm is the variable name used to reference the form you created.
vb.net 2003 does not seem to have a forms collection like vb6, while vb.net 2005 does have it:
http://www.dotnet247.com/247reference/msgs/21/107856.aspx
http://www.vbforums.com/showthread.php?t=387971

in depending on the version you are, you will have to manage all your forms, or be able to use
My.Application.OpenForms

Hi schenkp,

Are your forms children? In this case, you can go through the MDIChildren collection:
        For Each frmChild As Form In Me.MdiChildren
            frmChild.Close()
        Next

Cheers!
Avatar of schenkp
schenkp

ASKER

Cant get this to work, here is the code i am using, its get launched when a user selects the menu option...

                EC45 ec4 = new EC45();
                ec4.Show();
                ec4.PlayMedia(@"C:\\music.mp3");
                ec4.Owner = this;

There is a timer in the program and when it counts down to zero I am trying to close EC45 form and its not working?
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial