Solved

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

Posted on 2002-07-10
13
231 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 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

12 Experts available now in Live!

Get 1:1 Help Now