Solved

Clear contents of all controls

Posted on 2002-06-03
3
136 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

Technology Partners: 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

Title # Comments Views Activity
Printing problem 2 110
LAN or WAN ? 11 105
Embarcadero C++ builder XE10.1 Berlin find In files dialogue stunted display 4 73
How to make Sign in, using Clientdataset? 1 33
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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