Solved

Clear contents of all controls

Posted on 2002-06-03
3
133 Views
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.
0
Comment
Question by:brettawv
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
Comment Utility
for i := 0 to componentcount-1 do
begin
  if components[i] is tlabel then
    tlabel(components[i]).caption := '';
  if components[i] is tedit then
    tedit(components[i]).text := '';
  ...etc
end;

hint
search an ancestor, where the mostly controls are arrived from

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
oops ... brackets missed

if (.. is ..) then
0
 
LVL 6

Expert Comment

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


For example:

Type
  TMyControl=class(TControl)///dummy class
end;


For loopint:=0 to self.ControlCount-1 do
begin
   TMyControl(Controls[loopint]).text:='';
end;




Good luck!!


0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now