Solved

Destruction of visual controls at runtime

Posted on 1999-01-25
2
155 Views
Last Modified: 2010-04-06
Hi,

I have a list of buttons defined in a TComponentList. I can place these buttons on a form by setting the parent property

(ComponentList.Items[i] as TButton).Parent := Form1;

This works fine and the buttons display on the form, however I now wish to change the contents of ComponentList and re-draw the buttons on the form.

My question is how do I get rid of the buttons already on the form?

I have tried

(ComponentList.Items[i] as TButton).Free;

This certainly messes up the buttons but they are still on the form.

I have tried

(ComponentList.Items[i] as TButton).Parent := nil;

Does nothing!, well I sure it does but I know not what.

Regards

Chris
0
Comment
Question by:ChrisBerry
2 Comments
 
LVL 13

Accepted Solution

by:
Epsylon earned 50 total points
ID: 1363205
Try TForm.RemoveControl instead of (ComponentList.Items[i] as TButton).Parent := nil
Then you may use TButton.Free if you want to destroy the button component.
0
 

Author Comment

by:ChrisBerry
ID: 1363206
Hi,

Thanks for your answer. I in fact had another problem where I was overlaying two sets of buttons and not knowing so.

(ComponentList.Items[i] as TButton).Free;

and

(ComponentList.Items[i] as TButton).Parent := nil;

both work fine, I just did not know it because a set of buttons remained.

Thanks

Chris


0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
Delphi Dbf export problem to a Visual Foxpro application 6 189
Simple Delphi Question 9 89
Delphi Form ownership 4 89
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question