470,833 Members | 1,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

MDI app & events

I'm currently creating an mdi application and trying to use events between
various forms within the app for communication.

I have the events working without any problem when all the forms are open
but my problem comes when a form that has subscribed to an event is closed
and the event handler is not removed.

I think I've caused myself problems with the way that I open one form from
to make things easier the code below is in the Display form (showing
summary info) and it is opening a add form:

this.Cursor = Cursors.WaitCursor;
AddOrder add = new AddOrder();
add.OrderAdded += new
add.MdiParent = this.MdiParent;
catch (Exception)

this.Cursor = Cursors.Arrow;

Since I don't keep a reference to the AddOrder form that I added the handler
too when I close the Display form that originally created the AddOrder form
I am unable to remove the handler and an error is occuring when I raise an
event in the AddOrder form.

Any ideas of a good way to deal with removal of event handlers in this
situation or not raising the event?
Jun 3 '06 #1
1 946
I found a solution in that in my form I kept an ArrayList of forms that
I had opened and if I closed I looped through the ArrayList and ensured
I removed all of the event handlers.

Jun 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by jphelan | last post: by
3 posts views Thread by Trevor | last post: by
3 posts views Thread by Lance | last post: by
reply views Thread by BigAl.NZ | last post: by
1 post views Thread by Scott M. | last post: by
7 posts views Thread by Scott Stark | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.