Link to home
Start Free TrialLog in
Avatar of mmouer
mmouer

asked on

IndexOutOfRangeException on form.Dispose or form.Close

The error: "System.IndexOutOfRangeException" occurs when I CLose or Dispose a form I'm developing. As near as I can tell the system returns and executes all of the ComboBox click events after calling the Dispose function.

Why does it do this?

Shouldn't it just Dispose of the form and exit?

Michael
Avatar of BlackTigerX
BlackTigerX

are you creating components dinamically when you create the form?

and can you show the code you have to create and dispose that form?
I'm sure the problem is somewhere in the way you create/dispose the form
Avatar of mmouer

ASKER

No I am not creating components dynamically.

The form is made by creating a new Windows Form application and it contains:

1 Label
4 ComboBoxes
3 Buttons
1 DataGridView
1 Binding Navigator

Avatar of mmouer

ASKER

I fixed it by manually disposing of each control that has a click event before I dispose of the form.

I thought this was supposed by the CLI.

Thanks for your help,

Michael
ASKER CERTIFIED SOLUTION
Avatar of bsmuehmer
bsmuehmer
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial