Solved

Clear contents of all controls

Posted on 2002-06-03
3
138 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
[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
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 7051589
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
ID: 7051592
oops ... brackets missed

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

Expert Comment

by:DrDelphi
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:

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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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