Wrox Programmer Forums
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2007, 01:51 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default MDI Children

hi expert
how can i test that one specific form (such as frmCh1) was added to the parent MDI Form ?
i wanna don't allow to add more than one instance a child form to MDI form at same the time

what action i do?
thanks and regards
 
Old June 12th, 2007, 09:36 AM
Authorized User
 
Join Date: Sep 2006
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to VerbatimBOT Send a message via Yahoo to VerbatimBOT
Default

I believe you could use something like this before opening new child form
Code:
for each (Form frm in this.MdiChildren)
{
frm.Close();
}
Check out the MdiChildren property (or something like that, I can't recall it right now).

Programmer/Application developer
Belgrade, Serbia
 
Old June 12th, 2007, 09:48 AM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by VerbatimBOT
 I believe you could use something like this before opening new child form
Code:
for each (Form frm in this.MdiChildren)
{
frm.Close();
}
Check out the MdiChildren property (or something like that, I can't recall it right now).

Programmer/Application developer
Belgrade, Serbia
with this code all of my MDI child Forms will be close
i don't want outher form become close
i want if a specific child form can not be add to the mdi Form when an instance of it also added to MDI parent FOrm
 
Old June 14th, 2007, 01:46 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following should work for you

In the Event that opens a new instance of your child form (usually a menu command or command button), use the following code

if (MdiChildren.Length < 1)
          {
              childForm frm = new childForm();
          }
          else
          {
              MessageBox.Show("There are too many Windows open " +
                  ", please close one",
                  "Warning", MessageBoxButtons.OK,
                  MessageBoxIcon.Warning);
          }

 
Old June 14th, 2007, 03:36 PM
Friend of Wrox
 
Join Date: Dec 2006
Posts: 176
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks
but i want to don't alow the same forms to be load in MDIParent but i wanna to allow the diferrents mdi Chid be able to add to the mdiParent
 
Old June 28th, 2007, 06:08 AM
Registered User
 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Enslave
Default

Quote:
quote:thanks
but i want to don't alow the same forms to be load in MDIParent but i wanna to allow the diferrents mdi Chid be able to add to the mdiParent
Well, I had the same problem as u had before.. My way of solving it was to, every time the user asked to create a new MDI child, you give the child a name.. ie:

newMdiChild.Name = "name";

the trick is, before u create the new mdi child, you check if there's any other mdi childs with that same name
ie:

foreach (mdiChild mdi in this.mdichildren)
{
if (mdi.Name == "name")
{
mdi.Close();
}
}


something like that (dont have my code up atm.. so rewrite it with correct spelling and stuff ^^ )

hope it'll help

Enuff enuff!

C# btw.





Similar Threads
Thread Thread Starter Forum Replies Last Post
MDI & MDI Child Forms Menu's in VB2005 yulyos Visual Studio 2005 0 September 7th, 2007 09:49 AM
Controlling MDI child form from MDI parent panel LuxCoder Pro Visual Basic 2005 1 May 25th, 2007 12:20 PM
Controlling MDI child form from MDI parent panel LuxCoder VB How-To 1 April 9th, 2007 03:25 PM
MDI children flickering during opening form vs2003team General .NET 0 December 12th, 2005 08:10 AM
MDI Maximized children forms without controlbox pjbcoetzer C# 1 April 13th, 2005 12:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.