这样用DELPHI给MEMO组件的每行添加编号 10
1个回答
展开全部
定义一个变量i ,每加一行自加1.这下面是我写的,希望对你有用。
var
i,j,k:Integer;
S:String;
F:TextFile;
begin
if SaveDialog1.Execute then
begin
ADOQuery1.DisableControls;
try
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
S:='';
for i :=0 to ADOQuery1.FieldCount-1 do
begin
S:=S+ADOQuery1.Fields.Fields[i].FieldName+' | ';
end;
Writeln(F,S);
ADOQuery1.First;
k:=1;//编号
while not ADOQuery1.Eof do
begin
s:='';
for J:=0 to ADOQuery1.FieldCount-1 do
begin
s:=s+ADOQuery1.Fields.Fields[j].AsString+' | ';
end;
S:=IntToStr(k)+'|'+s;
Writeln(F,S);
ADOQuery1.Next;
Inc(k);//编号自加
end;
CloseFile(F);
except
end;
ADOQuery1.EnableControls;
end;
end;
var
i,j,k:Integer;
S:String;
F:TextFile;
begin
if SaveDialog1.Execute then
begin
ADOQuery1.DisableControls;
try
AssignFile(F,SaveDialog1.FileName);
Rewrite(F);
S:='';
for i :=0 to ADOQuery1.FieldCount-1 do
begin
S:=S+ADOQuery1.Fields.Fields[i].FieldName+' | ';
end;
Writeln(F,S);
ADOQuery1.First;
k:=1;//编号
while not ADOQuery1.Eof do
begin
s:='';
for J:=0 to ADOQuery1.FieldCount-1 do
begin
s:=s+ADOQuery1.Fields.Fields[j].AsString+' | ';
end;
S:=IntToStr(k)+'|'+s;
Writeln(F,S);
ADOQuery1.Next;
Inc(k);//编号自加
end;
CloseFile(F);
except
end;
ADOQuery1.EnableControls;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询