Clear contents of all controls

Posted on 2002-06-03
Medium Priority
Last Modified: 2010-04-04
I need to clear the contents of all my controls tedit, tlabel, etc.  How can I clear the contents of all controls without specifying each control such as Form1.Label1, Form1.Edit1, etc.
Question by:brettawv
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
LVL 27

Accepted Solution

kretzschmar earned 400 total points
ID: 7051589
for i := 0 to componentcount-1 do
  if components[i] is tlabel then
    tlabel(components[i]).caption := '';
  if components[i] is tedit then
    tedit(components[i]).text := '';

search an ancestor, where the mostly controls are arrived from

meikl ;-)
LVL 27

Expert Comment

ID: 7051592
oops ... brackets missed

if (.. is ..) then

Expert Comment

ID: 7051624
Create a dummy descendaent of TControl to access it's protected Text property and them typecast each control as that dummy class.

For example:

  TMyControl=class(TControl)///dummy class

For loopint:=0 to self.ControlCount-1 do

Good luck!!


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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