473,408 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Calling sub in MDI child forms

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


Nov 20 '05 #1
4 2869
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" <iM*****@hotmail.com> wrote in message
news:br**********@sparta.btinternet.com...
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

Nov 20 '05 #2
* "Merlin" <iM*****@hotmail.com> 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>
Nov 20 '05 #3
Many thanks to both of you.

Best Regards,
Merlin

"Merlin" <iM*****@hotmail.com> wrote in message
news:br**********@sparta.btinternet.com...
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

Nov 20 '05 #4
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" <iM*****@hotmail.com> wrote in message
news:br**********@sparta.btinternet.com...
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

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jon Hyland | last post by:
Ok, I'm a little rusty on this, it should be a simple problem but I can't figure it out. How can I handle form events in my main code page?? I'm creating a Windows App in C#. Rather than make...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
1
by: Mickey Swanson | last post by:
I have a MDI app wich has several different forms I need to call a method on one MDIchild form from another child form. I have a MDI form called frmMDI. I have a mdichild form called frmMain....
5
by: Randy | last post by:
The following code, which runs when I click File->Save in my main form, finds my save button in my mdi child for just fine. The question is: how do I invoke the Save method in the child form? ...
7
by: Chris | last post by:
Background: We have developed an C# MDI (Multi-Document Interface) application which loads different assemblies/forms, so that the user can have many "application windows" running within the...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
5
by: Earl | last post by:
I need to call a method on an owned child form, and am wondering if the best way of doing this is to capture the Closing event of the form that passes control back to the form where I have the...
1
by: nupuragr82 | last post by:
I have a parent form and on button click I am calling a child page where i have a textbox and a button. On button click of child form I am passing the value of the Textbox to the Textbox in parent...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.