473,385 Members | 1,606 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.

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
another,
to make things easier the code below is in the Display form (showing
summary info) and it is opening a add form:

try
{
this.Cursor = Cursors.WaitCursor;
AddOrder add = new AddOrder();
add.OrderAdded += new
AddOrder.OrderAddedEventHandler(this.OrderAdded);
add.MdiParent = this.MdiParent;
add.Show();
}
catch (Exception)
{

throw;
}
finally
{
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 1019
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
0
by: jphelan | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was...
3
by: Trevor | last post by:
Hello, How can I setup an event in C#? I would like for class A to have an event, and class B to intercept the event. Class B should not be able to call the event itself, only class A. How is...
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
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...
2
by: Mike | last post by:
Greetings, It would seem that this topic has been discussed at some length, but I was unable to discern whether there was a clear cut solution to resolve and/or otherwise workaround the issue. ...
0
by: BigAl.NZ | last post by:
Hi Guys, I am trying to write/copy some code that uses events with a GPS. Everytime the GPS position updates the event fires. The GPS code is from a SDK Library that I got called GPS Tools...
1
by: Scott M. | last post by:
I'm trying to get my head around what's involved in C# to declare, raise and respond to an event. I'm coming from the VB.NET world where to declare and event we wrote: Public Event Foo() To...
4
by: RgeeK | last post by:
From my newbie perspective I understand that Javascript is a single threaded environment and so interrupt-driven events are going to be somewhat challenging. But, I have an issue which seems to...
7
by: Scott Stark | last post by:
Hello, I've got some code working but I'm not sure that the way I implemented it is the best way. I have a custom collection class with a boolean property HasChanged that tells me if any of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.