我想将listbox中选中的值(无后缀的文件名),作为LoadFromFile()的参数,如下面的程序所示,但是调不通,请帮帮看一下,谢谢procedure TForm1.ListBox1Click(Sender: TObject); var aa,bb:tstringlist; i:integer; filepath:string; begin aa:=tstringlist.Create; bb:=tstringlist.Create; filepath:=listbox1.items[listbox1.itemindex]+'.txt' aa.LoadFromFile(filepath); for i:=0 to aa.Count-1 do begin bb:=SplitString(aa.Strings[i],','); stringgrid1.Rows[i]:=bb; end; aa.Free; bb.Free; end;
procedure TForm1.Button1Click(Sender: TObject); var str:string; begin str:=listbox1.Items.Strings[listbox1.itemindex]; application.MessageBox(pchar(str),'',mb_ok) end;
var
aa,bb:tstringlist;
i:integer;
filepath:string;
begin
aa:=tstringlist.Create;
bb:=tstringlist.Create;
filepath:=listbox1.items[listbox1.itemindex]+'.txt'
aa.LoadFromFile(filepath);
for i:=0 to aa.Count-1 do
begin
bb:=SplitString(aa.Strings[i],',');
stringgrid1.Rows[i]:=bb;
end;
aa.Free;
bb.Free;
end;
var str:string;
begin
str:=listbox1.Items.Strings[listbox1.itemindex];
application.MessageBox(pchar(str),'',mb_ok)
end;
bb是TStringList。而SplitString是什么类型的呢??
如是在当前EXE目录下--->
filepath:=Extractfilepath(application.exename)+listbox1.items[listbox1.itemindex]+'.txt'