StrataFrame Forum

How to access other form's methods and property from Main MDI parent

http://forum.strataframe.net/Topic18274.aspx

By Edhy Rijo - 8/2/2008

Hi all,

I have an MDI parent form with some controls, I need to access another opened form's methods from the main form, but I don't know how.  I would need to test if that 2nd form is opened then call its methods and refresh it.  How can this be done? 

Please some sample code if possible.

Thanks!

By Edhy Rijo - 8/2/2008

Humm, I found a way to access the 2nd form's methods like this:

'-- Loop through all MDIChildren forms and when found the one we need,

'-- use CType() to get access to its custom public methods.

For Each loForm As Form In Me.MdiChildren

     If loForm.Name = "frmCallMonitor" Then

          CType(loForm, frmCallMonitor).CheckUncheckCallsInList()     ' This is a Public custom method in that form.

          Exit For

     End If

Next

So far this work, but I am not sure if there is a better way than looping all the MdiChildren collection.

By Trent L. Taylor - 8/3/2008

I wouldn't use the name but rather test on the type:

If loForm.GetType() Is GetType(MyFormType) Then
   '---
End If

But other than that, the MDIChildren should work fine.

By Edhy Rijo - 8/3/2008

Thanks Trent.