Home All Groups Group Topic Archive Search About

Deleting all forms in collection

Author
14 Jan 2006 8:48 PM
Yuk Tang
I have created my own custom forms called baseform, inheriting normal
form properties and such.  Baseform is, as can be expected, the basis
for the other forms in my project.  I want to close all forms
whenever the x is clicked on any of those forms, so I go to the
closing event and cycle through the forms collection, closing each of
them down like so.

either

Forms(n).Close

or

Systems.Windows.Forms(n).Close

or something similar.  But to my surprise, I don't get the count
property as an option to get n number of forms, and manually putting
in a number doesn't offer close as a valid method either.  My guess
was that, since baseform inherits from form, so baseform would be
part of the forms collection as a result.

I can work around it by putting in a method that checks and closes
each form by name, but I'd have thought looping through the
collection via index numbers would be a simpler solution.

I have the feeling that I'm missing something obvious here.  Can
someone help?  Thanks.


--
Cheers, ymt.

Author
15 Jan 2006 12:22 AM
Jumeli
Hello,
Cant we use
dim f1 as form
For each f1 in system.windows.forms
if  f1.isopen  is true f1.close
next

???
Try it out.
Sorry if i dint catch your point.


Show quoteHide quote
"Yuk Tang" <jim.lak***@yahoo.com> wrote in message
news:Xns974BD3A7E7E0Ajimlaker2yahoocom@130.133.1.4...
>I have created my own custom forms called baseform, inheriting normal
> form properties and such.  Baseform is, as can be expected, the basis
> for the other forms in my project.  I want to close all forms
> whenever the x is clicked on any of those forms, so I go to the
> closing event and cycle through the forms collection, closing each of
> them down like so.
>
> either
>
> Forms(n).Close
>
> or
>
> Systems.Windows.Forms(n).Close
>
> or something similar.  But to my surprise, I don't get the count
> property as an option to get n number of forms, and manually putting
> in a number doesn't offer close as a valid method either.  My guess
> was that, since baseform inherits from form, so baseform would be
> part of the forms collection as a result.
>
> I can work around it by putting in a method that checks and closes
> each form by name, but I'd have thought looping through the
> collection via index numbers would be a simpler solution.
>
> I have the feeling that I'm missing something obvious here.  Can
> someone help?  Thanks.
>
>
> --
> Cheers, ymt.
Author
19 Jan 2006 7:55 PM
Yuk Tang
Thanks.


--
Cheers, ymt.