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;