var i:Integer; Lab:array of TLabel;begin if length(Lab)> 0 then //判斷是否已經(jīng)創(chuàng)建,如果有就刪除 begin for i:=0 to Length(Lab)-1 do begin FreeAndNil(Lab[i])
; end; end; SetLength(Lab,ADOQuery1.FieldCount)
; for i :=0 to ADOQuery1.FieldCount-1 do begin Lab[i]:=TLabel.Create(Self); Lab[i].AutoSize:=True; Lab[i].Parent:=Panel1; Lab[i].Top:=Trunc((i div 8)*70)
; //每行8個,每個間隔70 Lab[i].Left:=Trunc((i mod 8)*70)
; Lab[i].Caption:=ADOQuery1.Fields.Fields[i].FieldName; Lab[i].Color:=clRed; end;我已經(jīng)加了注釋。