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

Home Posts Topics Members FAQ

How to fire an event from the MDI parent to a child window?

Can anyone tell me how an MDI parent can fire an event that the child window
can pick up?

We have a MDI parent window containing 2 child windows (named 1 and 2).
Child window 2 updates and fires an event to say it has updated that the main
MDI parent can pick up on. I cannot find a way for the MDI parent to say to
Child window 1 that Child Window 2 has been updated?

Any help would be appreciated?
Thanks
mike
Jan 26 '07 #1
2 1658
There are a number of ways, more are prolly more correct than the one I
propose.

I like to keep the state of the data seperate from the forms. So in this
case I would create a state object that is shared among the forms. I then
register to receive event notification from this shared object. There are a
couple of ways to do this as well. Here is one way.

public class DataState

event Dataupdated(sen der as object, e as eventargs)

private shared objDataState as DataState

shared Sub new
objdatastate = new DataState
end sub

public shared readonly property Instance as DataState
get
return pobjdatastate
end get
end property

end Class

public class Form1
public sub new
'after initialize
addhandler datastate.insta nce.DataUpdate, addressof OnDataUpdate
end sub

private sub OnDataUpdate(se nder as object, e as eventargs)
'Handle event here
end sub

end class
The IssueVision project on www.windowsforms.com has another way of
implementing notifications between forms.
"sonicm" <so****@discuss ions.microsoft. comwrote in message
news:49******** *************** ***********@mic rosoft.com...
Can anyone tell me how an MDI parent can fire an event that the child
window
can pick up?

We have a MDI parent window containing 2 child windows (named 1 and 2).
Child window 2 updates and fires an event to say it has updated that the
main
MDI parent can pick up on. I cannot find a way for the MDI parent to say
to
Child window 1 that Child Window 2 has been updated?

Any help would be appreciated?
Thanks
mike

Jan 26 '07 #2
Mike,

I had never tried that before, so my code might not be the best way to
accomplish this. However, this worked for me:

On my mdi form, Form1:

Public Event MDIEvent()

On my child form, Form2:

Private WithEvents mdiForm As Form1

Private Sub Form2_Load(...) Handles MyBase.Load

Me.mdiForm = Me.MdiParent

End Sub

Private Sub mdiForm_MDIEven t() Handles mdiForm.MDIEven t

MsgBox("MDIEven t handled in child form")

End Sub

Kerry Moorman
"sonicm" wrote:
Can anyone tell me how an MDI parent can fire an event that the child window
can pick up?

We have a MDI parent window containing 2 child windows (named 1 and 2).
Child window 2 updates and fires an event to say it has updated that the main
MDI parent can pick up on. I cannot find a way for the MDI parent to say to
Child window 1 that Child Window 2 has been updated?

Any help would be appreciated?
Thanks
mike
Jan 26 '07 #3

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

Similar topics

5
1616
by: LuB | last post by:
I am programming in an event model - and I need to delete dynamically allocated memory. I apologize if this question is to Windows specific - but I think it has more to do with alloc and deallocating heap based mem. Imagine if you will, a parent window - creating a child window dynamically. When the child window is Destroyed, the child window needs to delete itself. I don't believe the child window tells the parent when he is
1
5810
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the MDI child window. My application does certain logic when the user actually closes the MDI child form by clicking the "X" in the upper right hand. My application, however, should not execute this logic if the user closes the MDI parent. I...
4
2761
by: Earl Teigrob | last post by:
I am thinking about using a popup window to edit settings that will affect parent asp.net page. The data that is changed in the popup window will be saved to the datastore that is loaded and displayed by the parent page. In order to refresh the parent page, I would like to raise an event in the popup (child) page that is subscribed to by the parent so that I can rebind the data in the parent page once the data in the child window data is...
6
19253
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I know, this shouldn't be an issue, but I just can't get it to work. The script only needs to work with Firefox/Mozilla, so XP code isn't an issue. I have tried to open a window like so.
0
8392
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
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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
8503
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
8605
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
7324
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
6163
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
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.