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

Forms Dispose method triggering SelectedIndexChanged event on close


I'm a C# Newbie, so if I've missed the obvious here go easy!!!

I have a form opened from a MDI parent. The form has a data bound
combo box, with a SelectedIndexChanged event (fills a list view box on
the same form depending on selection). It all works fine except when
you close either the form itself or it's MDI parent. Somehow as the
form is closing this event is triggered, and crashes out with an un-
handled error (even though it's in a try catch block!!) when it gets
to the part where it has to read the combo box value, which now has
been disposed along with the control.

The error goes away completely when I comment out the auto-generated
components.Dispose(); part of the form's class. In my limited
knowledge, I guess this to be either one of two strange occurances:
1. The Dispose method is itself triggering the SelectedIndexChanged
event, or
2. The close event somehow triggers the SelectedIndexChanged event but
the dispose kills the control as it it running.

I'm not sure what is going on here - but would appreciate any input.
The event definition appears to be normal:

this.comboBox2.SelectedIndexChanged += new
System.EventHandler(this.comboBox2_SelectedIndexCh anged);

And there are no other references to the function elsewhere in the
forms class. I'm a little stumped at what's going on here! Any help
appreciated!

Bill

Jul 26 '07 #1
0 1981

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

Similar topics

24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
3
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
6
by: Ayende Rahien | last post by:
Excetremely annoying problem, I've an application with a long startup time. So I created another form with my logo in it to as a splash screen. The splash screen is run from another thread and is...
0
by: Hector | last post by:
I have a ComboBox set up in a non-modal form. When a selection is made from the ComboBox, the handler code closes the form, but then the system crashes because of an unhandled NullReferenceException....
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
0
by: Bruce | last post by:
I have an MDI parent form frmMain that *should* allow multiple instances of a child form frmChild. The frmChild operates completely independently of frmMain (aside from being an MDI child), and...
12
by: Capt_Ron | last post by:
Sorry to have to ask this but... I have a form that asks for SQL connection information. I want to close the form when I click Save and then open the login form. I can Hide the form but it...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
8
by: AAaron123 | last post by:
If I show a form with ShowDialog and Dispose it FormClosing does not appear to run. At least I think that is true. If I want FormClosing and FormClose to run am I suppose to call the forms...
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...
0
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,...
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...
0
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...
0
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,...
0
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...

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.