Solved

how to set property value for all of one kind of TControl

Posted on 2002-07-10
13
230 Views
Last Modified: 2010-04-04

Dear Adviser !

I create a from with several Tedit, several button, serveral DBgrid ....

I want to set Enabled with False for all TEdit.

I know how to get the Tcontrol, but i dont know the kind of control

ChildCotrol : TControl
For i:= 1 to Form.ControlCount do
  ChildControl := form.Controls[i] ;

I wantt to set the value of TexBox, dont need to know object's name

Thank for consider





0
Comment
Question by:NamCit
  • 7
  • 6
13 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7145367
Hello

  You can do that using Is operator with the Class name
var
  I : integer;
begin
  for I:= 1 to ControlCount -1 do
  if Controls[I] is TEdit then
    Controls[I].Enabled := False;
end;

Best regards
0
 

Author Comment

by:NamCit
ID: 7145385

Thanks you  so much.

Please answear me a more question.

1./ How i know the type of variable ?
2./ How i know the whether variable is empty or not. If Empty a number is zero, Empry a string as ''

Because i create a Form to get data return.

I am learning Delphi. A lot of new things


0
 

Author Comment

by:NamCit
ID: 7145417

Please answear two questions for me again.

Thanks so much

0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7145427
Hello

 here are some functions to help you to test the Numeric values


function IsInt(S : string) : Boolean;
begin
  Try
    StrToInt(S);
    Result := True
  Except
    Result := False;
  end;
end;

function IsFloat(S : string) : Boolean;
begin
  Try
    StrToFloat(S);
    Result := True
  Except
    Result := False;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Not IsInt(Edit1.Text) then
    ShowMessage('You have to enter Interger Value');

  if Not IsFloat(Edit1.Text) then
    ShowMessage('You have to enter Numeric Value');
end;
==

if you want to test if the Edit1 is empty or not
  if Edit1.Text ='' then
    ShowMessage('You have to enter a Value');  

Best regards
0
 

Author Comment

by:NamCit
ID: 7145429


IF i set Enabled property. It Is ok.

But if i set Text property. It is wrong.

Please show me the code to set TEdit.Text with ''
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7145437
use

   TEdit(Controls[I]).Text := '';
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:NamCit
ID: 7145439


Delphi doese not support the function to know the kind of variable and the value of variable is empty or not

If not, i will use your comment
0
 

Author Comment

by:NamCit
ID: 7145446


TEdit(Controls[I]).Text := '';  ?

I try :
  HopDongForm.Controls[I].Text := '';

But not correct

Hearing any news
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7145464
use
TEdit(HopDongForm.Controls[I]).Text := '';

I saw a mistake by me

start the loop with 0 not 1
for I:= 0 to ControlCount -1 do

delphi doesn't has a function like IsEmpty that found in VB
0
 

Author Comment

by:NamCit
ID: 7145474

It is ok .

i have solve my problem. Thank you so much.

Mr mnasman, Please explain clearly to me.

Why doest TEDIT mean ? Is is a function ?

I bother you so much today
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 20 total points
ID: 7145553
TEdit is the class of EditBoxs, and we used it to typecasting the control to use the properties like Text, and Edit1 is an object of the Class TEdit

you can use the other classes to like
TCheckBox, TForm, TLabel, and more
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7145571
NamCit, this is not fair
after all this work, you gave me grade B, it's only 20 points :(
0
 

Author Comment

by:NamCit
ID: 7145595

sory Mr. Mnasman !

How many points ? I am a new Dp programmer . So i ask a easy question.

Please answear for me this question agai

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20321966

so you could hepl me more

you are very kind
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

17 Experts available now in Live!

Get 1:1 Help Now