CF2 UserControl Dispose

R

Ryan

Hi All,

I could use a bit of help with Compact Framework and the Dispose method.
I have written an application which is made up as follows:

MyHintLabel is derived from UserControl
MyEditControl is derived from UserControl

MyEditControl is made up of a MyHintLabel and an edit control such as
TextEdit or Combo as defined in an XML document. This control also has
and resize event to position the label and edit control components.

EditTab which is a class which creates a tab page and adds the required
number of MyEditContols and handles the loading and saving of data from
them. Each EditTab item is saved to a List object and added to a tab
control on the main form.

Everything works OK until the application exits then I get Object
Disposed Exceptions occurring in the MyEditControl’s resize event.
Looking at the object the MyEditControl has been disposed BUT the
dispose function in MyEditControl.Designer.cs hasn’t been called for
example this.controls.count will cause an object disposed exception as
well as this.mylabel.bounds = new Rectangle (0, 0, labelWidth,
this.mylabel.height);

I can handle the exceptions and ignore them but this seems to slow down
the exiting of the application quite a bit. I’ve tried hanging off the
Disposed event to check when and item is gone but this doesn’t seem to
fire at all.

Any help and pointers would be greatly appricated.

Tanks
Ryan
 
F

Fabien

R

Ryan

Fabien wrote:

Hi Fabien,

Thanks for the pointer, very useful link coming from a C/C++ & Delphi
background. I've managed to alter the code to manually dispose
everything and set NULL values where needed to stop other code running.

Thanks once again for the help.

Take Care,
Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top