🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #448

Re: Problem with closing an MDI Child Windows

#448
From: Peter Jones
Date: Tue, 25 Oct 2005 14:21
43 lines
2362 bytes
"Marc Rohloff [TeamB]" <"on request"> wrote:
>On 24 Oct 2005 09:03:04 -0700, Peter Jone wrote:
>> But the problem is when I click Close menu item to close the 
>> Child, it is never closed. 
>
>How about:
>
>> //Event when click the NewChild Menu item
>> private void miNewChild_Click(object sender, System.EventArgs e)
>> {
>>   frmChild objfrmChild = GetfrmChildInstance();
>>   objfrmChild.BringToFront();
>> }
>
>> //Check if any Child instance is created
>> public frmChild GetfrmChildInstance()
>> {
>>   if (this.g_objfrmChild == null)
>>   {
>>     //if not created yet, Create an instance
>>     this.g_objfrmChild = new frmChild();
>>     this.g_objfrmChild.MdiParent = this;
>>     this.g_objfrmChild.Show();
>>   }
>> 
>>   return this.g_objfrmChild;
>> }
>
>You should probably avoid the global variable and just use the
>MdiChildren and ActiveMdiChild property of the form, i.e. just use
>  ActiveMdiChild.Close();

Hi Marc, Thanks for your help.

Now the app works better, since I can close the 
this.g_objfrmChild by doing this.ActiveMdiChild.Close(). But 
how come closing the Child does not automatcally set it to 
null. So even though the Child is closed, next time I click 
NewChild menu item no Child is displayed. Any suggestions?

Regards,
Peter
Technical Details
Message-ID: <435e3f58$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!news-out.usenet.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <435d05b8$1@newsgroups.borland.com> <1dhje2fm97vwb.dlg@marcrohloff.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,5065392821169b29
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter Jones" <peter@hotmail.com>
Sender: "Peter Jones" <peter@hotmail.com>
Reply-To: "Peter Jones" <peter@hotmail.com>
Subject: Re: Problem with closing an MDI Child Windows
Newsgroups: borland.public.csharpbuilder.language.csharp
X-User-Info: 65.94.193.112     
References: <435d05b8$1@newsgroups.borland.com> <1dhje2fm97vwb.dlg@marcrohloff.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <435e3f58$1@newsgroups.borland.com>
Date: 25 Oct 2005 07:21:12 -0700
X-Trace: newsgroups.borland.com 1130250072 207.105.83.66 (25 Oct 2005 07:21:12 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!news-out.usenet.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail