?
Solved

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

Posted on 2002-07-10
13
Medium Priority
?
234 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
[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
  • 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
Independent Software Vendors: 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!

 
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
 

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 60 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

752 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