473,385 Members | 1,645 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,385 software developers and data experts.

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 1646
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(sender 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.instance.DataUpdate, addressof OnDataUpdate
end sub

private sub OnDataUpdate(sender 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****@discussions.microsoft.comwrote in message
news:49**********************************@microsof t.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_MDIEvent() Handles mdiForm.MDIEvent

MsgBox("MDIEvent 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
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...
1
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...
4
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...
6
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.