469,907 Members | 2,188 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,907 developers. It's quick & easy.

MDI child forms


I have an MDI form and a child form to go with it.
The child form is called frmChild. There is also a button
on the MDI form and when pressed invokes the following
code

-------------------------
dim frm as new frmChild

frm.mdiparent = me

frm.show()
-------------------------

How can I loop through all of the visible forms in this
MDI ? (e.g. stop more than one instance of the same child
form appearing - or count the number of instances taht
exist before opening up another)

Thanks
Gerry
Nov 20 '05 #1
2 1062
Gerry,
this is what im using to only allow one instance of a child form
and to count a form

Dim FRM As Form

For Each FRM In Me.MdiChildren
If FRM.Text = "frmChildfm" Then
' do something with child form if found
FRM.Focus() 'force child form to show once found
Exit Sub
else
frmchild.show ' else load a new instance of form
End If
Next

Now to count the child forms

Dim FRM As Form
Dim cnt As Integer = 0
Dim total As Integer = 0

For Each FRM In fmMain.MdiChildren
If FRM.Text = "frmChildfm" Then
cnt += 1 ' count number of specific form
End If
total += 1 ' count total number of child forms
Next

Hope this helps
tony
Nov 20 '05 #2
"Gerry" <an*******@discussions.microsoft.com> schrieb

I have an MDI form and a child form to go with it.
The child form is called frmChild. There is also a button
on the MDI form and when pressed invokes the following
code

-------------------------
dim frm as new frmChild

frm.mdiparent = me

frm.show()
-------------------------

How can I loop through all of the visible forms in this
MDI ? (e.g. stop more than one instance of the same child
form appearing - or count the number of instances taht
exist before opening up another)


The Container has an MdiChildren property.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by James Spibey | last post: by
3 posts views Thread by Maheshkumar.R | last post: by
3 posts views Thread by Lance | last post: by
reply views Thread by Bruin | last post: by
2 posts views Thread by Lenster | last post: by
reply views Thread by Scott H. | last post: by
reply views Thread by emalcolm_FLA | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.