PC Review


Reply
Thread Tools Rate Thread

Closing forms opened with show when parent form closes

 
 
RD
Guest
Posts: n/a
 
      6th Dec 2003
Dim myfrm as new frmb
myfrm.show()

Dim myfrm2 as new frmc
myfrm2.show

Opens two forms from a butom located on forma

when I close forma I would like both form myfrm and for myfrm2 to close
automatically

Can anyone tell me how or point me to some sample code that does this type
of thing?

Thank you for any help

Bob




 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      6th Dec 2003
"RD" <(E-Mail Removed)> schrieb
> Dim myfrm as new frmb
> myfrm.show()
>
> Dim myfrm2 as new frmc
> myfrm2.show
>
> Opens two forms from a butom located on forma
>
> when I close forma I would like both form myfrm and for myfrm2 to
> close automatically
>
> Can anyone tell me how or point me to some sample code that does this
> type of thing?


Form A has a closed event. Handle the event (or overwrite OnClosed) and
close the other forms by calling their Close methods.

You can also make form A the owner of the other forms, so they be will
automatically closed when form A is closed, but the owned forms (B and C)
will always be in front of the owner form (A). In addition, the owned forms
will automatically be minimized when the owner form is minimized. The might
be useful - but if you don't want this behavior you can go the first way.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
RD
Guest
Posts: n/a
 
      6th Dec 2003
Thanks Armin,
But that is exactly what I can't figure out how to do.

The Dim for the myFrm as new frmb is in thebutton_click event so the
instance that is open (myfrm) can not be referenced directly from within the
formA's closed event. It is out of scope because Myfrm is private to the
button_click event. So how do you refer to it in the code in the closed
event?


To refer or not to refer, that is the question ;-)

Bob

"Armin Zingler" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "RD" <(E-Mail Removed)> schrieb
> > Dim myfrm as new frmb
> > myfrm.show()
> >
> > Dim myfrm2 as new frmc
> > myfrm2.show
> >
> > Opens two forms from a butom located on forma
> >
> > when I close forma I would like both form myfrm and for myfrm2 to
> > close automatically
> >
> > Can anyone tell me how or point me to some sample code that does this
> > type of thing?

>
> Form A has a closed event. Handle the event (or overwrite OnClosed) and
> close the other forms by calling their Close methods.
>
> You can also make form A the owner of the other forms, so they be will
> automatically closed when form A is closed, but the owned forms (B and C)
> will always be in front of the owner form (A). In addition, the owned

forms
> will automatically be minimized when the owner form is minimized. The

might
> be useful - but if you don't want this behavior you can go the first way.
>
>
> --
> Armin
>
> http://www.plig.net/nnq/nquote.html
> http://www.netmeister.org/news/learn2quote.html
>



 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      6th Dec 2003
"RD" <(E-Mail Removed)> schrieb
> Thanks Armin,
> But that is exactly what I can't figure out how to do.
>
> The Dim for the myFrm as new frmb is in thebutton_click event so
> the instance that is open (myfrm) can not be referenced directly from
> within the formA's closed event. It is out of scope because Myfrm is
> private to the button_click event. So how do you refer to it in the
> code in the closed event?
>
>
> To refer or not to refer, that is the question ;-)


Declare the variables at class level (= as fields of the class; named
"Module Scope" in the following chapter):

http://msdn.microsoft.com/library/en...copeLevels.asp



see also:
http://msdn.microsoft.com/library/en...odsToClass.asp
http://msdn.microsoft.com/library/en...fVBSpec7_5.asp



--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Determining if form was opened in a Parent form fredg Microsoft Access Form Coding 1 19th Dec 2006 02:56 AM
Closing an MDI Parent Form =?Utf-8?B?S2F0aHkgRA==?= Microsoft Dot NET 0 18th Jul 2005 03:16 PM
Close all forms, then closing MDI Parent Help =?Utf-8?B?TWljaGFlbA==?= Microsoft VB .NET 2 22nd Jun 2005 01:54 PM
Closing modeless form causes parent form to disappear (or lose focus). Marcus Microsoft Dot NET Framework Forms 1 3rd Jan 2004 03:30 PM
Closing child forms in MDI parent one? al Microsoft VB .NET 6 15th Dec 2003 08:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 AM.