请问不同窗体间 使用控件出错的原因
请教不同窗体间 使用控件出错的原因
我的程序为MDI模式,一个主窗体A(动态创建)调用了一个子窗体B(动态创建),为了要实现DBGRID的数据插入,我又建了一窗体C.
C窗体的属性为
Name (FrmSelectGoods)
BorderStyle (bsSingle)
FormStyle (fsStayOnTop)
B调用C
var FrmSelectGoods:TFrmSelectGoods;
begin
FrmSelectGoods:=TFrmSelectGoods.Create(Application);
FrmSelectGoods.Visible:=false;
FrmSelectGoods.Show;
end;
B窗体的一个按钮事件(单击后出现错误)
uses UntSelectGoods;
procedure TFrmSalesOrdersDetail.Button4Click(Sender: TObject);
begin
FrmSelectGoods.ComboBox1.Text:='abc';
end;
出错提示:
Debugger Exception Notification
Project jdxerp.exe raised exception class EAccessViolation with message 'Access violation at address 00531E7F in module ' jdxerp.exe'. Read of address 00000300'.Process stopped.Use Step or Run to continue.
不知何原因
------解决方案--------------------
在 procedure TFrmSalesOrdersDetail.Button4Click(Sender: TObject); 调用的时候 FrmSelectGoods并没有
初始化。
你在里边加上
if not Assigned(FrmSelectGoods) then
FrmSelectGoods:=TFrmSelectGoods.Create(Application);
我的程序为MDI模式,一个主窗体A(动态创建)调用了一个子窗体B(动态创建),为了要实现DBGRID的数据插入,我又建了一窗体C.
C窗体的属性为
Name (FrmSelectGoods)
BorderStyle (bsSingle)
FormStyle (fsStayOnTop)
B调用C
var FrmSelectGoods:TFrmSelectGoods;
begin
FrmSelectGoods:=TFrmSelectGoods.Create(Application);
FrmSelectGoods.Visible:=false;
FrmSelectGoods.Show;
end;
B窗体的一个按钮事件(单击后出现错误)
uses UntSelectGoods;
procedure TFrmSalesOrdersDetail.Button4Click(Sender: TObject);
begin
FrmSelectGoods.ComboBox1.Text:='abc';
end;
出错提示:
Debugger Exception Notification
Project jdxerp.exe raised exception class EAccessViolation with message 'Access violation at address 00531E7F in module ' jdxerp.exe'. Read of address 00000300'.Process stopped.Use Step or Run to continue.
不知何原因
------解决方案--------------------
在 procedure TFrmSalesOrdersDetail.Button4Click(Sender: TObject); 调用的时候 FrmSelectGoods并没有
初始化。
你在里边加上
if not Assigned(FrmSelectGoods) then
FrmSelectGoods:=TFrmSelectGoods.Create(Application);