473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 5001
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.microsoft.com> wrote in
message news:3E**********************************@microsof t.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.microsoft.com> wrote in
message news:3E**********************************@microsof t.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
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...
2
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...
1
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...
0
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...
7
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...
0
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...
0
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...
4
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...
0
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)...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.