Controlling MDI child form Instances

  • Thread starter Thread starter Marinos Christoforou
  • Start date Start date
M

Marinos Christoforou

Hello,

I have an Windows MDI application. I would like to only allow one instance
of a child form tpo be open at any particular time. Can somebody suggest a
way to do this?
 
You could use the MdiChildren property.

Private Function FormTypeDisplayed(ByVal formType As Type)
For Each form As Windows.Forms.Form In Me.MdiChildren
If form.GetType Is formType Then
Return True
End If
Next
Return False
End Function

You could use it like this:
If Not FormTypeDisplayed(GetType(Form1)) Then
Dim f As New Form1
f.MdiParent = Me
f.Show()
End If


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
Back
Top