为什么用了edit1.text:=opendialog1.filename后,运行没有任何反映,并没有将文件名显示在edit里。 我注意到opendialog1控件里有一个filename属性,可那里是空的,编辑它会叫你选择一个文件?另外如用edit1.Text := opendialog1.Files.Strings[0];在运行时出现了下面的错误: debugger exception notification Project XX.exe raised exception class EstringListError with message 'List index out of bounds(0)'.process stopped.Use Step or Run to continue. (ok/help) 强制运行出现: List index out of bounds(0) 请再次指教。谢谢。
if Opendialog1.Execute then edit1.Text := OpenDialog1.FileName;
if Opendialog1.Execute then edit1.Text := opendialog1.Files.Strings[0];
if Opendialog1.Execute then //必须有这一句 edit1.Text := opendialog1.Files.Strings[0];
edit1.Text := opendialog1.Files.Strings[0];
我注意到opendialog1控件里有一个filename属性,可那里是空的,编辑它会叫你选择一个文件?另外如用edit1.Text := opendialog1.Files.Strings[0];在运行时出现了下面的错误:
debugger exception notification
Project XX.exe raised exception class EstringListError with message 'List index out of
bounds(0)'.process stopped.Use Step or Run to continue. (ok/help)
强制运行出现:
List index out of bounds(0)
请再次指教。谢谢。
edit1.Text := OpenDialog1.FileName;
edit1.Text := opendialog1.Files.Strings[0];
edit1.Text := opendialog1.Files.Strings[0];
那移到哪里?
你看一下是否在FORM1的OnCreate事件或OnActivate事件里有
opendialog1.EXECUTE
字样
“但我的form2是通过form1里的一个按钮调用的”这个onclick事件
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ToolWin, ComCtrls, ImgList, ExtCtrls;type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
URL1: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
menuImage: TImageList;
N13: TMenuItem;
N14: TMenuItem;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
Bevel1: TBevel;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
TreeView1: TTreeView;
procedure N14Click(Sender: TObject);
procedure N8Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.N14Click(Sender: TObject);
begin
form2.Show
end;procedure TForm1.N8Click(Sender: TObject);
begin
application.Terminate;
end;end.