Home > Back-end >  Edit control quantity according to query the field number and show how much... Please help modify co
Edit control quantity according to query the field number and show how much... Please help modify co

Time:10-12

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:

Here as many technical staff less and less, nobody should send a post a lot of day, ah, good carry of the BBS is like this,,,?

CodePudding user response:

Adoquery1.Com ponentCount
This is wrong, should read the whole window controls,

CodePudding user response:

refer to the second floor ZBDZJX response:
adoquery1.Com ponentCount
This is wrong, should read the whole window controls,

This should be changed to the form, I know, but this it not:
 if (Components [I] is TEdit) and (TEdit (Components [I]). The Name [5] in [' 0 '... '4']) then 

If I have 20 columns, 15, 30 column? Every time the query the names of the different number of columns is different, how to change? The Name [5] in [' 0 '... '4'] how did this change?

CodePudding user response:

reference u011443248 reply: 3/f
Quote: refer to the second floor ZBDZJX response:

Adoquery1.Com ponentCount
This is wrong, should read the whole window controls,

This should be changed to the form, I know, but this it not:
 if (Components [I] is TEdit) and (TEdit (Components [I]). The Name [5] in [' 0 '... '4']) then 

If I have 20 columns, 15, 30 column? Every time the query the names of the different number of columns is different, how to change? The Name [5] in [' 0 '... '4'] how did this change?


Will TEdit (Components [I]). The Name [5] converted to an integer, compared with record number again, if it was 10, is strtoint (TEdit (Components [I]). The Name [5]) & lt; (=10, generally the statement)

CodePudding user response:

Can be used to dynamically create methods to achieve, just thinking, improved by oneself,
With the DBEDIT and relevance to the field,
 
Procedure TForm1. Button1Click (Sender: TObject);
Var
Lables: TLabel;
The Edits: TDBEdit;
I: integer;
The begin
For I:=1 to the self. Adoquery1. FieldCount do begin//create many fields with the same number
Lables:=TLabel. Create (self);//create a TAB and set to the field name
Lables. Top: 30 *=I;
Lables. Left:=10;
Lables. Width:=100;
Lables. Height:=25;
Lables. Parent:=the self;
Lables. Caption:=self. ADOQuery1. Fields [I - 1]. FieldName.
Lables. Name:='lable' + trim (inttostr (I));
Lables. Visible:=true;
The Edits:=TDBEdit. Create (self);//create DBEDIT and associated to the related field
The Edits. Top: 30 *=I;
The Edits. Left:=110;
The edits. Parent:=the self;
The Edits. The DataSource:=self. DataSource1;
The Edits. DataField:=self. ADOQuery1. Fields [I - 1]. FieldName;
Edits the Name:='edit' + trim (inttostr (I));
The Edits. Visible:=true;
end;
end;





  • Related