procedure TForm1.toGrid(Col: integer);
var
i:integer;
begin
stringgrid1.cells[col,0]:=DBGrid1.Columns.Items[col-1].FieldName;
with table1 do begin
first;
for i:=1 to RecordCount do begin
stringgrid1.cells[col,i]:=table1.fields[col-1].Asstring;
next;
end;
end;
end;
procedure TForm1.DBGrid1TitleClick(Column: TColumn);
var
i:byte;
begin
i:= Column.Index;
toGrid(i+1);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
table1.Open;
stringgrid1.ColCount:=table1.FieldCount+1;
stringgrid1.RowCount:=table1.RecordCount+1;
end;