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

Controls add/remove and Dispose

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
2 4883
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: et | last post by:
I have the situation where a C# dll is loaded and it provides some controls to display, I wrap the controls in some nice group boxes, and later on I dispose of the group boxes, making sure I remove...
8
by: jcrouse | last post by:
I have a test app with one button and a context menu. When I click on the button, it adds a label with some properties, one being the assignment of the context menu. If I add 5 buttons then want to...
8
by: Aaron Smith | last post by:
I have a problem... Have a form, made some changes.. now all the controls are gone. I didn't make any changes to the designer generated region.. I'm not really sure what happened to them, but this...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
8
by: hunanwarrior | last post by:
I added textbox controls to a form when user selects amount to create from a combobox as follows: 'Load up the combobox Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As...
1
by: Martin | last post by:
Hi all ! I use Visual Studio .NET 2005 SP1 (+ Updates for Vista) on Windows Vista. I have a strange problem in a WinForm application. In a UserControl, which inherit another UserControl...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following code the dynamically adds a specific number of controls. for x as integer = 1 to 10 Dim btn as Windows.Forms.Button = New Windows.Forms.Button btn.Name = "btn" & x btn.Text...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.