Solved

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

Posted on 2002-07-10
13
228 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:mnasman
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:mnasman
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:mnasman
ID: 7145437
use

   TEdit(Controls[I]).Text := '';
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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:mnasman
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:
mnasman 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:mnasman
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

16 Experts available now in Live!

Get 1:1 Help Now