mdi with and childform closing

A

andreas

I can open several childforms with the following sub in de mdi form after
clicking a button

Private Sub NewWindow()

Dim ch As New ChildForm()
ch.MdiParent = Me
ch.Text = "Textwindow nr " & Me.MdiChildren.Length.ToString
ch.Show()

end sub

I want to open automatically a new childform when the last childform is
closed or closing.

I have tried with a event but changing the line in the sub in <dim
Withevents
ch as new Childform()> fails.

Thanks for any response.
 
A

Armin Zingler

andreas said:
I can open several childforms with the following sub in de mdi form
after clicking a button

Private Sub NewWindow()

Dim ch As New ChildForm()
ch.MdiParent = Me
ch.Text = "Textwindow nr " & Me.MdiChildren.Length.ToString
ch.Show()

end sub

I want to open automatically a new childform when the last childform
is closed or closing.

I have tried with a event but changing the line in the sub in <dim
Withevents
ch as new Childform()> fails.

Withevents can only be used at class level because it internally adds
properties to the class. Properties can only be at class level, not a
procedure level. Use Addhandler/RemoveHandler instead.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
A

andreas

Thanks for the information.
I tried addhandler/removehandler but has no solution.
Who gives me a sample code ?
F.e. after closing a child let run a sub in the parent form
 
A

Armin Zingler

andreas said:
Thanks for the information.
I tried addhandler/removehandler but has no solution.
Who gives me a sample code ?

Dim ch As New ChildForm()
addhandler ch.closed, addressof onchildformclosed
ch.MdiParent = Me
ch.Text = "Textwindow nr " & Me.MdiChildren.Length.ToString
ch.Show()



private sub onchildformclosed(...)
removehandler (directcast(sender, form)).closed, _
addressof onchildformclosed
'open another form as written in your first post
F.e. after closing a child let run a sub in the parent form
'this can also be done here
end sub



--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top