473,657 Members | 2,540 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2893
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*****@hotmai l.com> wrote in message
news:br******** **@sparta.btint ernet.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*****@hotmai l.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).M yMethod()
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*****@hotmai l.com> wrote in message
news:br******** **@sparta.btint ernet.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*****@hotmai l.com> wrote in message
news:br******** **@sparta.btint ernet.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
17560
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 my main form the startup object, I'd rather put my Main() function in a class or code file. Why? Because thats what I always do in standard C++ or VB. In my opinion, writing all my application logic in the form itself is sloppy and only for...
8
4928
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, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
1
3079
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. I have a mdichild form called frmDetails. after saving changes to frmDetails I need to update frmMain
5
3839
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? Thanks.... protected void SaveMenuSelect(Object sender, System.EventArgs e) { Form form = (Form)this.ActiveMdiChild; foreach(Control c in form.Controls)
7
2109
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 same container. Some of these child forms need to use legacy code from a mature product written in C, and we have achieved this by compiling our C code into a DLL, and using DllImport directive to reference the functions that we need. The C#...
3
3203
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 container form) or if the MDI child form's Visible property is set to False (after the MDI child form was shown). This is an enormous problem for my app because I must show different MDI child forms based on the state of my application and many of the...
10
4008
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
3
3573
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 and then do a refresh of the calling form. Any ideas on how to get a reference to the calling form? I tried window.parent.location.reload() , but it doesn't work. Thanks a lot.
5
2241
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 method. The structure is like so: frmMain (MDI, runs on app start) calls frmB (MDI child), which in turn calls frmC (MDI child), which in turn calls frmD (MDI child). frmMain and frmB remain open while frmC and frmD are shown.
1
4018
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 page and now I want to fire an event. Button click event on parent page- parameter is txtBlank (TextBox in parent page) function SetRange(Src) { window.open("SetRange.aspx?src=" + Src, "_blank", "status = 1, ontop=true, height=110,...
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.