var
f1:TextFile;
str:string;
i:integer;
begin
with dbgrid1.datasource.dataset do
disablecontrols;
assignfile(f1,'c:/test.txt');
rewrite(f1);
first;
while not eof do
begin
str:='';
for i:=0 to fieldcount-1 do
str:=str+fields.asstring+' ';
writeln(f1,str);
next;
end;
fileclose(f1);
first;
enablecontrols;
end;
end;