以打开对话框为例: 在工程的窗体上放一EDIT1和OpenDialog1,Button1写入以下代码:procedure TForm1.Button1Click(Sender: TObject); var F: TextFile; S: string; begin if OpenDialog1.Execute then { Display Open dialog box } begin AssignFile(F, OpenDialog1.FileName); { File selected in dialog box } Reset(F); Readln(F, S); { Read the first line out of the file } Edit1.Text := S; { Put string in a TEdit control } CloseFile(F); end; end;
帮助里很清楚的,拖一个控件放在窗体上,然后f1……
在工程的窗体上放一EDIT1和OpenDialog1,Button1写入以下代码:procedure TForm1.Button1Click(Sender: TObject);
var F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
Reset(F);
Readln(F, S); { Read the first line out of the file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;