Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2002-07-10
13
Medium Priority
?
235 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
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!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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