Solved

Destruction of visual controls at runtime

Posted on 1999-01-25
2
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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