473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close all child forms

Hey, it's me again.
Is there a way to, when closing a form, close also all forms opened inside
this one? I'm not talking about MDI.
Let's say I create and open three forms in Form1. When I close Form1, and
he's not the main form of my app, I want to close all the three forms I
opened.
It would be nice to do that without a Form[] collection so I don't need to
iterate throut it.

Thanks.
Nov 17 '05 #1
2 5024
You can use the "Owner" property of the forms that are created and set this
property to this (or Me) of the form that opened them.
http://msdn.microsoft.com/library/de...OwnerTopic.asp

// ... in Form1

Form2 f2 = new Form2();
f2.Owner = this;

Form3 f3 = new Form3();
f3.Owner = this;

f2.Show();
f3.Show();

--
Tim Wilson
..NET Compact Framework MVP

"Bruno Rodrigues" <Br************ @discussions.mi crosoft.com> wrote in
message news:3E******** *************** ***********@mic rosoft.com...
Hey, it's me again.
Is there a way to, when closing a form, close also all forms opened inside
this one? I'm not talking about MDI.
Let's say I create and open three forms in Form1. When I close Form1, and
he's not the main form of my app, I want to close all the three forms I
opened.
It would be nice to do that without a Form[] collection so I don't need to
iterate throut it.

Thanks.

Nov 17 '05 #2
Thank you very much!

"Tim Wilson" wrote:
You can use the "Owner" property of the forms that are created and set this
property to this (or Me) of the form that opened them.
http://msdn.microsoft.com/library/de...OwnerTopic.asp

// ... in Form1

Form2 f2 = new Form2();
f2.Owner = this;

Form3 f3 = new Form3();
f3.Owner = this;

f2.Show();
f3.Show();

--
Tim Wilson
..NET Compact Framework MVP

"Bruno Rodrigues" <Br************ @discussions.mi crosoft.com> wrote in
message news:3E******** *************** ***********@mic rosoft.com...
Hey, it's me again.
Is there a way to, when closing a form, close also all forms opened inside
this one? I'm not talking about MDI.
Let's say I create and open three forms in Form1. When I close Form1, and
he's not the main form of my app, I want to close all the three forms I
opened.
It would be nice to do that without a Form[] collection so I don't need to
iterate throut it.

Thanks.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1274
by: clu82 | last post by:
I have an MDI app that allows the user to open multiple client address child forms. The user has a child form open that has client id "1001" and the records associated data displayed. If the user chooses to open a new child form and then try to select client id "1001" again, I would like to automatically close this form and bring the other form that already had client "1001" to the front. With the code below, I can find the correct...
2
9019
by: Guy Babbitt | last post by:
I have an MDI application that starts an instance of a child form at application start. I have an event handler on a combo box checking for the selected value to change. When the select value changes, I call a method on the parent form to change some menu options, and then I need to close the child form. My code looks something like this: private void ddlDatabase_SelectedIndexChanged(object sender, System.EventArgs e) {...
1
4225
by: Martin Douglas | last post by:
Hey guys, maybe someone can help me with some MDI issues I have. A co-worker asked me a very simple question, one that I blew off as trivial, and it has become a time-consuming issue. Simply put, there is an MDIForm and a child form. The MDIForm does the usual from within its constructor... this.IsMdiContainer = true; Form2 frm = new Form2();
0
1445
by: Bruce | last post by:
I have an MDI parent form frmMain that *should* allow multiple instances of a child form frmChild. The frmChild operates completely independently of frmMain (aside from being an MDI child), and the frmChild close event occurs via a button on frmChild (from within the code of frmChild). I need to be able to dynamically create multiple separate instances of frmChild from frmMain. The problem: If two (or more) frmChild's are opened,...
7
2519
by: Alice | last post by:
Hi, In my program, the user can navigate to many different forms. When they go to the next form, I want the form they have left to close. However, the forms aren't closing. Can anyone tell me what I'm doing wrong? Here is a sample snippet of code where the user can return to the main form while simultaneously closing the previous form.
0
1721
by: Tom | last post by:
Let's say I have an MDI parent that has 5 open child windows in it. Now let's say that I have a function in the MDI parent that attempts to close all the child windows. It's starts running, closing the child windows; however, let's say that the second window it attempts to close has a Closing event and in that event (for whatever reason) the e.Cancel gets set to true (maybe the user is in the middle of something and doesn't want that window...
0
486
by: Bill | last post by:
Hi I have a parent child forms. I want the close, maximize, and minimize buttons to be removed. One the child form I have set the maximize and minimize buttons to false. I have the child form mamiximze in the parent form. So then the maximized button is still active. But I want the child form to fill the parent form without the ability to close minimize or maximize the form like a default page.
4
2772
by: LCAdeveloper | last post by:
Help! Another newbie question I'm afraid. I have a toolbar on an MDI form, which I can control OK to produce a child form. When the child form is active, the appropriate MDI parent form toolbar button properties are set as follows: .pushed=true and .enabled=false. My problem is how do I set the reverse conditions when I close this child form? I have tried putting (in the Exit button click event) Toolbar1.Buttons(6).Pushed=False...
0
1252
by: bmwm3 | last post by:
Hi: New to C#, I have a MainForm (parent) that can potentially have multiple child forms (in a tabbed interface). Mainform has closing event defined for "Close All" (through a menu option) which basically gives user list of all child forms and asks if want to be saved or not. Similarly, each child form has "Close" which gives a warning about closing that specific form without saving.
3
2192
by: =?Utf-8?B?RGF2ZVA=?= | last post by:
I've got a situation in a VB 2003 Windows application with an MDI form and a child form. In certain situations, when the child is closed by the user, I also want to close the MDI parent. Is there a way to close the MDI parent with code in the child form? In the MDI child form, I have tried: me.MDIParent.Close but that doesn't appear to work. Is that because of object references in
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.