Delphi Traversal Control

Source: Internet
Author: User

There are 10 edit controls, named Edt1,edt2,edt3 ... EDT10, how do you know which edit control's value is empty with a loop? Procedure Tform1.button2click (Sender:tobject);
Var
I:integer;
Begin
For i:=0 to Self.componentcount-1 Do//self.componentcount is the number of controls TForm1
Begin
If Self.components[i] is tedit then//Judging if the control is Tedit
Begin
if (Self.components[i] as Tedit). Text= "then ShowMessage (self.components[i). Name);
End
End
End
With this function findcomponent (const name:string) you can find any control you want and then determine if it is empty. Using the Tedit.findcomponents (edit (I)) function, I is the ordinal of the control, specifically look at the help!
Another way is to give their tag the same value, such as 1, the other default is zero, the program is as follows:
Procedure Tform1.button2click (Sender:tobject);
Var
I:integer;
Begin
For i:=0 to Self.componentcount-1 Do//self.componentcount is the number of controls TForm1
Begin
If Self.components[i] is tedit then//Judging if the control is Tedit
Begin
if (Self.components[i] as Tedit). Text= ")
and (Self.components[i] as Tedit). tag=1) Then
ShowMessage (Self.components[i]. Name);
End
End
End

Delphi Traversal Control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.