Home > Back-end >  According to the number of adoquery query database columns, display the Edit control number!!!!!!!!!
According to the number of adoquery query database columns, display the Edit control number!!!!!!!!!

Time:10-12

If I pass adoquery query to:
If the query to "wang" has five fields, then Edit controls display Edit1 Edit2, Edit3, Edit4, Edit5,
If query "xiao li" four column, then Edit1-4 controls all, according to
Total field is not more than 5, so how to write code?

CodePudding user response:

 procedure TForm1. Button1Click (Sender: TObject); 
Var I: integer;
The begin
For I:=0 to do form1.Com ponentCount - 1
If the Components [I] is TEdit then
TEdit (Components [I]). The Visible:=
Strtoint (TEdit (Components [I]). The Name [5]) & lt;=ADOQuery1. FieldCount;
end;

CodePudding user response:

Or:
 procedure TForm1. Button1Click (Sender: TObject); 
Var I: integer;
The begin
For I:=0 to 4 do
If the Components [I] is TEdit then
TEdit (Components [I]). The Visible:=
Strtoint (TEdit (Components [I]). The Name [5]) & lt;=ADOQuery1. FieldCount;
end;

CodePudding user response:

Oh, no, to be like this:
 procedure TForm1. Button1Click (Sender: TObject); 
Var I: integer;
The begin
For I:=0 to do form1.Com ponentCount - 1
If (Components [I] is TEdit) and (TEdit (Components [I]). The Name [5] in [' 0 '... '4']) then
TEdit (Components [I]). The Visible:=
Strtoint (TEdit (Components [I]). The Name [5]) & lt;=ADOQuery1. FieldCount;
end;

CodePudding user response:

The
reference 3 floor gzzai response:
oh, no, to be like this:
 procedure TForm1. Button1Click (Sender: TObject); 
Var I: integer;
.

Upstairs to inform, the following code can change:
Procedure TForm2. Button2Click (Sender: TObject);
Var
I: integer;
SQLSTR: string;
The begin
ADOQuery3. Close;
ADOQuery3. SQL. The Clear;
ADOQuery3. SQL. The Add (' select * from sheet1 where AAA='" + trim (edit1. Text) + "' ");
Adoquery3. Open; The
SQLSTR:=';
For I:=0 to ADOQuery3. Do FieldCount - 1
If ADOQuery3. Fields [I]. Text='is' then SQLSTR:=SQLSTR +', '+ ADOQuery3. Fields [I] FieldName.
SQLSTR='select' SQLSTR: + + 'from sheet2 where AAA=' "+ ADOQuery3. Fieldbyname (" AAA"). AsString + "'" ';
ADOQuery1. Close;
ADOQuery1. SQL. The Clear;
Adoquery1. SQL. The add (SQLSTR);
Adoquery1. Open;
end;

Procedure TForm2. Button3Click (Sender: TObject);
Var I: integer;
The begin
For I:=0 to do adoquery1.Com ponentCount - 1
If (Components [I] is TEdit) and (TEdit (Components [I]). The Name [5] in [' 0 '... '4']) then
TEdit (Components [I]). The Visible:=false;
end;
Remarks: the above adoquery3 is a line, the query in the sheet1 AAA is the bank in the cell for all "yes" column in the adoquery1 shows that if there are 100 column in the sheet1, and AAA cell "is" the field for five, BBB line cell "is" the field is nine, CCC line 12 cell is "yes",,,,,,, different for different fields,
I think through the AAA finally query out five fields, the EDIT control will show Edit1 - Edit5, BBB query nine field, eventually will show Edit1 - Edit9, Edit1 - Edit9 corresponding BBB query column (column 1 to 9,
How to modify it, thank you!

CodePudding user response:

How yao people,,,,

CodePudding user response:

How to change???
  • Related