PC Review


Reply
Thread Tools Rate Thread

Calling sub in MDI child forms

 
 
Merlin
Guest
Posts: n/a
 
      10th Dec 2003
Hi,

Can someone please help.

I wish to loop through all my MDI children and call a sub procedure I have
created, my problem is that the sub procedure may not exist in all the MDI
children so the program crashes.

What is the best way to tackle this.

Thanks.

Merlin




 
Reply With Quote
 
 
 
 
Jan Tielens
Guest
Posts: n/a
 
      10th Dec 2003
In your loop you should check the type of each form. If the types matches
the type of your "special" form, then you can use the method:

For Each form As Form In Me.MdiChildren
If form.GetType Is GetType(Form1) Then
CType(form, Form1).MyMethod()
End If
Next


--
Greetz

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


"Merlin" <(E-Mail Removed)> wrote in message
news:br6nca$3t2$(E-Mail Removed)...
> Hi,
>
> Can someone please help.
>
> I wish to loop through all my MDI children and call a sub procedure I have
> created, my problem is that the sub procedure may not exist in all the MDI
> children so the program crashes.
>
> What is the best way to tackle this.
>
> Thanks.
>
> Merlin
>
>
>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      10th Dec 2003
* "Merlin" <(E-Mail Removed)> scripsit:
> I wish to loop through all my MDI children and call a sub procedure I have
> created, my problem is that the sub procedure may not exist in all the MDI
> children so the program crashes.


\\\
Dim f As Form
For Each f In Me.MdiChildren
If TypeOf f Is MyChildForm1 Then
DirectCast(f, MyChildForm1).MyMethod()
End If
Next f
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
 
Reply With Quote
 
Merlin
Guest
Posts: n/a
 
      10th Dec 2003
Many thanks to both of you.

Best Regards,
Merlin

"Merlin" <(E-Mail Removed)> wrote in message
news:br6nca$3t2$(E-Mail Removed)...
> Hi,
>
> Can someone please help.
>
> I wish to loop through all my MDI children and call a sub procedure I have
> created, my problem is that the sub procedure may not exist in all the MDI
> children so the program crashes.
>
> What is the best way to tackle this.
>
> Thanks.
>
> Merlin
>
>
>
>



 
Reply With Quote
 
IbrahimMalluf
Guest
Posts: n/a
 
      10th Dec 2003
As an alternative to looping through each form with an If...Then you could
create a class whose purpose is to raise application wide events and expose
it as a property of a module.

Then each MDI Child that should respond to a given event could subscribe to
that class and react to the event.



--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================



"Merlin" <(E-Mail Removed)> wrote in message
news:br6nca$3t2$(E-Mail Removed)...
> Hi,
>
> Can someone please help.
>
> I wish to loop through all my MDI children and call a sub procedure I have
> created, my problem is that the sub procedure may not exist in all the MDI
> children so the program crashes.
>
> What is the best way to tackle this.
>
> Thanks.
>
> Merlin
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a method in one MDI child from another MDI child Earl Microsoft Dot NET Framework Forms 5 21st Dec 2006 08:30 AM
Calling a method in one MDI child from another MDI child Earl Microsoft C# .NET 5 21st Dec 2006 08:30 AM
calling an mdi child from an mdi child Bernie Yaeger Microsoft VB .NET 1 3rd Jan 2005 03:45 AM
mdi and child forms - view tabcontrol in child form andreas Microsoft VB .NET 1 23rd Jun 2004 04:27 AM
Calling sub in MDI child forms Merlin Microsoft VB .NET 1 10th Dec 2003 11:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 PM.