By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,205 Members | 1,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,205 IT Pros & Developers. It's quick & easy.

Controls add/remove and Dispose

P: n/a
Hi,

If I add programatically a Panel to a control, and a Label add to that
Panel. Then when I Dispose the Panel do I have to Dispose the Label
also, or does the Panel take care of that ? And if it is do I gain time
doing it myself or not ?

I ask this because if I for example put panels or labels on Mappoint
ActiveX control, and I don't dispose them myself it take a lot of time
to destroy the activeX control. But maybe this is not the truth with
dotNet controls like a panel or label ?

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Jan 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Wilfried,

Here's a tip. First, create a Panel in your form. Add a label to it. Then
look at the designer-generated code. All you have to do then is write the
code which does this by essentially copying the designer-generated code.
Whatever it does when it adds the panel and the label, you do the same.
Whatever it does when disposing the form, you do the same.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Wilfried Mestdagh" <wi******@mestdagh.bizwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
Hi,

If I add programatically a Panel to a control, and a Label add to that
Panel. Then when I Dispose the Panel do I have to Dispose the Label also,
or does the Panel take care of that ? And if it is do I gain time doing it
myself or not ?

I ask this because if I for example put panels or labels on Mappoint
ActiveX control, and I don't dispose them myself it take a lot of time to
destroy the activeX control. But maybe this is not the truth with dotNet
controls like a panel or label ?

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz

Jan 31 '07 #2

P: n/a
The simplest rule:
If an object implements IDisposable (has a "Dispose" method), then your code
should call that method. Otherwise, "don't worry, be happy".
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Wilfried Mestdagh" wrote:
Hi,

If I add programatically a Panel to a control, and a Label add to that
Panel. Then when I Dispose the Panel do I have to Dispose the Label
also, or does the Panel take care of that ? And if it is do I gain time
doing it myself or not ?

I ask this because if I for example put panels or labels on Mappoint
ActiveX control, and I don't dispose them myself it take a lot of time
to destroy the activeX control. But maybe this is not the truth with
dotNet controls like a panel or label ?

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Feb 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.