By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,723 Members | 1,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,723 IT Pros & Developers. It's quick & easy.

MDI gets FormClosing but non-Child forms also open do not.

P: n/a
I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens followed
by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This is
true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms do
not receive the events.

Is that correct???


Thanks
Nov 6 '06 #1
Share this Question
Share on Google+
13 Replies

P: n/a
I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form is
the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution then
to download it.
But is the someplace I can upload it so some of you experts might comment -
I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms do
not receive the events.

Is that correct???


Thanks


Nov 6 '06 #2

P: n/a

Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form is
the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks



Nov 7 '06 #3

P: n/a
Academic Hi,

I assume that there is a Forms collection for the application.

If you close the MDI, then, if your intention is truly to end the whole
application, loop, For Each, thru the Forms collection and close each one
individually except the MDI parent.

That should solve your problem although I haven't tried it in VB.NET.

On a philosophical level, you might reconsider why you have to have non-MDI
child forms floating around. That is - unless they are modal forms.

Garry
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.com. ..
>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>>I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form
is the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #4

P: n/a
Academic,

There are about 12 methods to start a form, it depends from those methods
how you have to close a form.

Probably as you show how you start them, it will be easier to reply on your
question.

Cor

" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms do
not receive the events.

Is that correct???


Thanks


Nov 7 '06 #5

P: n/a
The application is closing so naturally all forms must close

Thanks
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.com. ..
>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>>I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form
is the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #6

P: n/a
But if the application is closing the system will close all forms so I'd
expect the events to be called.

"Garry" <ga**********@gmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Academic Hi,

I assume that there is a Forms collection for the application.

If you close the MDI, then, if your intention is truly to end the whole
application, loop, For Each, thru the Forms collection and close each one
individually except the MDI parent.

That should solve your problem although I haven't tried it in VB.NET.

On a philosophical level, you might reconsider why you have to have
non-MDI child forms floating around. That is - unless they are modal
forms.

Garry
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.com. ..
>>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>>>I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form
is the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event.
This is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #7

P: n/a
Really 12 ways. Maybe you're onto something.
In the real program, in the MdiContainer I do
If gFormCapture Is Nothing Then gFormCapture = New FormCaptureTool

gFormCapture.Show()

gFormCapture.BringToFront()

In the simple test program, in the MdiContainer I do

Imports System.Windows.Forms

Public Class MDIParent1

Private Sub MDIParent1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing MDI")

End Sub

Private Sub MDIParent1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim z As New Form1

z.Show()

End Sub

End Class

In the non-Mdi non-Child I do

Public Class Form1

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing Form1")

End Sub

End Class
THANKS
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ou****************@TK2MSFTNGP03.phx.gbl...
Academic,

There are about 12 methods to start a form, it depends from those methods
how you have to close a form.

Probably as you show how you start them, it will be easier to reply on
your question.

Cor

" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks



Nov 7 '06 #8

P: n/a
Academic,

Have a look at the form mdichildren.collection, you probably can come there
with contains (the last I am not sure of) otherwise just looping.

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

The nothing is not so good for this,

I hope this helps,

Cor
" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Really 12 ways. Maybe you're onto something.
In the real program, in the MdiContainer I do
If gFormCapture Is Nothing Then gFormCapture = New FormCaptureTool

gFormCapture.Show()

gFormCapture.BringToFront()

In the simple test program, in the MdiContainer I do

Imports System.Windows.Forms

Public Class MDIParent1

Private Sub MDIParent1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing MDI")

End Sub

Private Sub MDIParent1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim z As New Form1

z.Show()

End Sub

End Class

In the non-Mdi non-Child I do

Public Class Form1

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing Form1")

End Sub

End Class
THANKS
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ou****************@TK2MSFTNGP03.phx.gbl...
>Academic,

There are about 12 methods to start a form, it depends from those methods
how you have to close a form.

Probably as you show how you start them, it will be easier to reply on
your question.

Cor

" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>>I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event. This
is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #9

P: n/a
Maybe I didn't explain good enough.

It is for form that is not a MdiChild that the events are missing.
The MdiChildren and the MdiContainer all receive the events.
The standard folder does not.

If you have two standard forms they receive the events.
If you change one to a MdiContainer the standard form (that is, the one that
is not the MdiContianer) no longer receives the events.
If you like to know about the non-run-of-the-mill situations try the example
below. I think you'll be surprised.
Simply make a solution with two forms and make one a MdiContainer (do NOT
make the other a MdiChild)
Make the MdiContainer the startup form.
Run.
Then exit the app by clicking the stop on the MdiContainer.
And watch the standard form closing event.

Thanks


"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:O7**************@TK2MSFTNGP04.phx.gbl...
Academic,

Have a look at the form mdichildren.collection, you probably can come
there with contains (the last I am not sure of) otherwise just looping.

http://msdn2.microsoft.com/en-us/lib...ichildren.aspx

The nothing is not so good for this,

I hope this helps,

Cor
" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Really 12 ways. Maybe you're onto something.
In the real program, in the MdiContainer I do
If gFormCapture Is Nothing Then gFormCapture = New FormCaptureTool

gFormCapture.Show()

gFormCapture.BringToFront()

In the simple test program, in the MdiContainer I do

Imports System.Windows.Forms

Public Class MDIParent1

Private Sub MDIParent1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing MDI")

End Sub

Private Sub MDIParent1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim z As New Form1

z.Show()

End Sub

End Class

In the non-Mdi non-Child I do

Public Class Form1

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Console.WriteLine("Closing Form1")

End Sub

End Class
THANKS
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ou****************@TK2MSFTNGP03.phx.gbl...
>>Academic,

There are about 12 methods to start a form, it depends from those
methods how you have to close a form.

Probably as you show how you start them, it will be easier to reply on
your question.

Cor

" Academic" <ac************@a-znet.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event.
This is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #10

P: n/a
You are going to have to close your forms yourself.
I don't understand what forms the user has open
and what is going on in your application. Just
because you close onevform, it does not necessarily
close all the forms, except in the case of
MDI parents/children.

If you want all forms to close when the MDI parent
is closed, you are going to have to code it that way.

I use a main form on my apps. From there, the user
can go to other forms. If he hits <Exiton any
form to exit the application, I put a close for
the main form in my Form_Closed event. Then in
the Form_Closing event of my main form, I loop
through the open forms and close them, and then
let my main form close.

Robin S.
" Academic" <ac************@a-znet.comwrote in message
news:eH**************@TK2MSFTNGP04.phx.gbl...
The application is closing so naturally all forms must close

Thanks
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.com. ..
>>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>>>I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form
is the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is very
significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
I have a MDI form, sometimes child forms and sometimes forms that are
neither
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..

But the regular forms that are also open do not receive that event.
This is true whether there are child forms open or not.

The MDI form is always open and always gets the events.

FormClosing works the same.
It appears to be true that if there is a MDI form other non-child forms
do not receive the events.

Is that correct???


Thanks




Nov 7 '06 #11

P: n/a
O.K. I've got it but I don't know why it's required. When I exit the app all
the forms are - I don't know what to call it if not "closed" - I guess
"exited" might be a better word if the events are not raised.

Since all the forms go away when the app is exited I guess I was assuming
they were closed.
Thanks for the info

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:e8******************************@comcast.com. ..
You are going to have to close your forms yourself.
I don't understand what forms the user has open
and what is going on in your application. Just
because you close onevform, it does not necessarily
close all the forms, except in the case of
MDI parents/children.

If you want all forms to close when the MDI parent
is closed, you are going to have to code it that way.

I use a main form on my apps. From there, the user
can go to other forms. If he hits <Exiton any
form to exit the application, I put a close for
the main form in my Form_Closed event. Then in
the Form_Closing event of my main form, I loop
through the open forms and close them, and then
let my main form close.

Robin S.
" Academic" <ac************@a-znet.comwrote in message
news:eH**************@TK2MSFTNGP04.phx.gbl...
>The application is closing so naturally all forms must close

Thanks
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.com ...
>>>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
I generated a simple solution that has only a MDI form and a non-MDI
non-MdiChild form.

I open the regular form in the Load event of the Mdi form. The Mdi form
is the startup.

Both FormClosing events contain a console writeline statement.

When I click the X to exit the app I see only the output from the Mdi
FormClosing event.

None from the regular form.

It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.

I suppose this behavior could be by design but that seems unlikely.

Not getting the close and closing events when they are relied on is
very significant.


" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>I have a MDI form, sometimes child forms and sometimes forms that are
>neither
>
>
If I close the app the child forms closing and closed event happens
followed by the Mdi form receiving the events..
>
But the regular forms that are also open do not receive that event.
This is true whether there are child forms open or not.
>
The MDI form is always open and always gets the events.
>
FormClosing works the same.
>
>
It appears to be true that if there is a MDI form other non-child
forms do not receive the events.
>
Is that correct???
>
>
>
>
Thanks
>
>




Nov 7 '06 #12

P: n/a
It's required because when you exit the app, the
forms are only closed if you close them. If you
check the Task Manager, you might find that
your app is still running. If you're running it
in the IDE, you probably have to click on the
stop button to get it to stop running.

Good luck.
Robin

" Academic" <ac************@a-znet.comwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
O.K. I've got it but I don't know why it's required. When I exit the app
all the forms are - I don't know what to call it if not "closed" - I guess
"exited" might be a better word if the events are not raised.

Since all the forms go away when the app is exited I guess I was assuming
they were closed.
Thanks for the info

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:e8******************************@comcast.com. ..
>You are going to have to close your forms yourself.
I don't understand what forms the user has open
and what is going on in your application. Just
because you close onevform, it does not necessarily
close all the forms, except in the case of
MDI parents/children.

If you want all forms to close when the MDI parent
is closed, you are going to have to code it that way.

I use a main form on my apps. From there, the user
can go to other forms. If he hits <Exiton any
form to exit the application, I put a close for
the main form in my Form_Closed event. Then in
the Form_Closing event of my main form, I loop
through the open forms and close them, and then
let my main form close.

Robin S.
" Academic" <ac************@a-znet.comwrote in message
news:eH**************@TK2MSFTNGP04.phx.gbl...
>>The application is closing so naturally all forms must close

Thanks
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.co m...

Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.

If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.

And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.

Robin S.
----------------------------------

" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
>I generated a simple solution that has only a MDI form and a non-MDI
>non-MdiChild form.
>
I open the regular form in the Load event of the Mdi form. The Mdi
form is the startup.
>
Both FormClosing events contain a console writeline statement.
>
When I click the X to exit the app I see only the output from the Mdi
FormClosing event.
>
None from the regular form.
>
It's really so simple that it might be easier to generate the solution
then to download it.
But is the someplace I can upload it so some of you experts might
comment - I'd hate to attach it.
>
I suppose this behavior could be by design but that seems unlikely.
>
Not getting the close and closing events when they are relied on is
very significant.
>
>
>
>
" Academic" <ac************@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl.. .
>>I have a MDI form, sometimes child forms and sometimes forms that are
>>neither
>>
>>
>If I close the app the child forms closing and closed event happens
>followed by the Mdi form receiving the events..
>>
>But the regular forms that are also open do not receive that event.
>This is true whether there are child forms open or not.
>>
>The MDI form is always open and always gets the events.
>>
>FormClosing works the same.
>>
>>
>It appears to be true that if there is a MDI form other non-child
>forms do not receive the events.
>>
>Is that correct???
>>
>>
>>
>>
>Thanks
>>
>>
>
>




Nov 8 '06 #13

P: n/a
thanks for the insight

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:bb******************************@comcast.com. ..
It's required because when you exit the app, the
forms are only closed if you close them. If you
check the Task Manager, you might find that
your app is still running. If you're running it
in the IDE, you probably have to click on the
stop button to get it to stop running.

Good luck.
Robin

" Academic" <ac************@a-znet.comwrote in message
news:u0**************@TK2MSFTNGP04.phx.gbl...
>O.K. I've got it but I don't know why it's required. When I exit the app
all the forms are - I don't know what to call it if not "closed" - I
guess "exited" might be a better word if the events are not raised.

Since all the forms go away when the app is exited I guess I was assuming
they were closed.
Thanks for the info

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:e8******************************@comcast.com ...
>>You are going to have to close your forms yourself.
I don't understand what forms the user has open
and what is going on in your application. Just
because you close onevform, it does not necessarily
close all the forms, except in the case of
MDI parents/children.

If you want all forms to close when the MDI parent
is closed, you are going to have to code it that way.

I use a main form on my apps. From there, the user
can go to other forms. If he hits <Exiton any
form to exit the application, I put a close for
the main form in my Form_Closed event. Then in
the Form_Closing event of my main form, I loop
through the open forms and close them, and then
let my main form close.

Robin S.
" Academic" <ac************@a-znet.comwrote in message
news:eH**************@TK2MSFTNGP04.phx.gbl...
The application is closing so naturally all forms must close

Thanks
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:E5******************************@comcast.c om...
>
Why would the non-MDI-child form be closed when you
close the MDI form? It's not a child of the MDI form,
and as far as it knows, it is not related in any way
to the MDI form. Closing the MDI form closes the
children (but not until after the MDI form is closed)
because they are related.
>
If you want to close the non-MDI-child form,
you will have to put something in the FormClosed
or FormClosing event of the MDI form that closes
it specifically.
>
And if you want the MDI form to close when the "normal"
form is closed, vice versa applies.
>
Robin S.
----------------------------------
>
" Academic" <ac************@a-znet.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl.. .
>>I generated a simple solution that has only a MDI form and a non-MDI
>>non-MdiChild form.
>>
>I open the regular form in the Load event of the Mdi form. The Mdi
>form is the startup.
>>
>Both FormClosing events contain a console writeline statement.
>>
>When I click the X to exit the app I see only the output from the Mdi
>FormClosing event.
>>
>None from the regular form.
>>
>It's really so simple that it might be easier to generate the
>solution then to download it.
>But is the someplace I can upload it so some of you experts might
>comment - I'd hate to attach it.
>>
>I suppose this behavior could be by design but that seems unlikely.
>>
>Not getting the close and closing events when they are relied on is
>very significant.
>>
>>
>>
>>
>" Academic" <ac************@a-znet.comwrote in message
>news:%2****************@TK2MSFTNGP02.phx.gbl. ..
>>>I have a MDI form, sometimes child forms and sometimes forms that are
>>>neither
>>>
>>>
>>If I close the app the child forms closing and closed event happens
>>followed by the Mdi form receiving the events..
>>>
>>But the regular forms that are also open do not receive that event.
>>This is true whether there are child forms open or not.
>>>
>>The MDI form is always open and always gets the events.
>>>
>>FormClosing works the same.
>>>
>>>
>>It appears to be true that if there is a MDI form other non-child
>>forms do not receive the events.
>>>
>>Is that correct???
>>>
>>>
>>>
>>>
>>Thanks
>>>
>>>
>>
>>
>
>




Nov 8 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.