MDI child forms

G

Gerry

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
 
A

Armin Zingler

Gerry said:
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.
 
T

T Perkins

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
 

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