新建一个工程 , 放一个TTable,连接DBDEMOS的biolife.db, 再放一个listbox,一个botton
数据是列了出来,但未完全对齐, 看是否你要的东西
procedure TForm1.Button1Click(Sender: TObject);
const
KONG = ' ';
begin
with ListBox1 do begin
Items.Clear;
with Table1 do begin
if Not Active then Open;
First;
while Not Eof do begin
Items.Add( Format('%-15s', [Trim(FieldByName('Species No').AsString)] ) + KONG +
Format('%-15s', [Trim(FieldByName('Category').AsString)] )+ KONG +
Format('%-30s', [Trim(FieldByName('Common_Name').AsString)] )+ KONG +
Format('%-40s', [Trim(FieldByName('Species Name').AsString)] )+ KONG +
Format('%-10s', [Trim(FieldByName('Length (cm)').AsString)] )+ KONG +
Format('%-10s', [Trim(FieldByName('Length_In').AsString)] )+ KONG +
Format('%-10s', [Trim(FieldByName('Notes').AsString)] )
);
Next;
end;
end;
end;
end;