title: delphi7 create component from table fields
body: <p>I want to create components (Panels) on run-time in Delphi 7 from a table, but only create if the field value is > 0.<br>Example:<br>widht |p1|p2|p3|p4|p5|p6|p7|..|px|<br>1500 | 5 | 5 | 5 | 0 | 0 | 0 | 0 |..|0 | // create 3 panels<br>2700 | 5 | 5 | 5 | 6 | 6 | 0 | 0 |..|0 | // create 5 panels<br>.......
  
  <pre><code> private
  { Private declarations }
  pn : array of TPanel;
  ..................................
  
  procedure TForm1.Button1Click(Sender: TObject);
  var i: integer;
  oldpn: TComponent;
  begin
  table1.SetKey;
  table1.FindNearest([form2.Edit2.Text]);
  i:= table1.FieldCount;
  SetLength(pn, i);
  for i:= 1 to i-1 do
   begin
    oldpn:= Findcomponent('pn'+inttostr(i));
    oldpn.Free;
    pn[i]:= TPanel.Create(form1);
    pn[i].Parent := form1;
    pn[i].Caption := 'Panel' + inttostr(i);
    pn[i].Name := 'pn'+inttostr(i);
    pn[i].Height := table1.Fields[i].Value ;
    pn[i].Width := 500;
    pn[i].Color:=clGreen;
    pn[1].Top := form1.ClientHeight - pn[1].Height;
    if (i &gt; 1) then pn[i].Top := pn[i-1].Top - pn[i].Height;
    pn[i].OnClick := pnClick;
   end;
  end;
  </code></pre>
  
  <p>This code create me the panels but for ALL fields. I want to be able to declare the 'pn' array only from fields with value > 0...<br>I ve tried:<br> if table1.Fields[i].Value > 0 then<br>begin<br>i:= table1.FieldCount....<br>but it does't work. Any idea? Thanks in advance!</p>