• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

MDI question

Hi,

I am trying out my first MDI app and I have a question. In my main MDIForm, I am able to create multiple instances of a child form. Is there a way for me to iterate thru all of the child forms, regardless of how many are up? I want to be able to do this without keeping a static counter. Also, if anyone could point me to a good site that could enlighten me on the ins and outs of VB MDI's I would appreciate it.

Thanks
0
jhamlett
Asked:
jhamlett
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
dim x as form

for each x in forms
   msgbox x.caption
next
0
 
ventondCommented:
   Dim I As Integer

    For I = 0 To Forms.Count - 1
       If TypeOf Forms(I) Is frmMyForm Then
           Forms(I).ZOrder 0
       End if    
    Next

Where frmMyform is the name of the from you are looking for. You might also do something like:

if Forms(I).caption = "ME" then
0
 
trkcorpCommented:
<<Is there a way for me to iterate thru all of the child forms, regardless
of how many are up?>> The way I do this is by using the forms collection.  I set the Tag property of all child forms to "child". For example I add a menu option under a Windows menu "Close all child windows".  The code looks like this:

Private Sub mnuWinCloseChild_Click()
Dim n as integer
On Error Resume Next
n=0
Do While n < Forms.Count
   If Forms(n).Tag = "child" Then
      Unload Forms(n)
   else
      n = n + 1
   End If
Loop
End Sub

Hope this helps...

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
trkcorpCommented:
PS: The reason the loop is While < Forms.Count is that Forms(1) will always be the MDI parent...
0
 
jhamlettAuthor Commented:
cool, those all work great. thanks for all the input.
0
 
trkcorpCommented:
jhamlett, you should accept or reject the "forced" answer by ventond.  If you leave this question sitting here "locked" few people will bother to look at it and give you further input...  
0
 
jhamlettAuthor Commented:
my bad, thought I had accepted the answer, hehe
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now