用DBgrid时,打算双击选中数据库中一行数据,然后将其显示到另外一个窗体的edit中出现错误,错误代码如下:
project projict1.ext raised exception class EAccessViolation with message 'Access violation at address 004F1D3F in module'Projiect1.exe'.Read of address 00000394'.Process stopped.Use Step or Run to continue.
project projict1.ext raised exception class EAccessViolation with message 'Access violation at address 004F1D3F in module'Projiect1.exe'.Read of address 00000394'.Process stopped.Use Step or Run to continue.
在赋值之前。加上下面代码:
if not Assigen(frmShow) then
frmShow := TfrmShow.create(Application);
//然后在进行赋值
frmShow.caption := adoquery1.fieldByName('xx').asstring;
var
hm:string; //非局部变量
Form1: TForm1;implementation
procedure TForm1.Button1Click(Sender: TObject);
begin
while not table1.Eof do
begin
if (chzz=table1.Fields[0].AsString) and (mm=table1.Fields[1].asstring) then
begin //新写的
flag:=true;
hm:=table1.Fields[2].Value;//新写的
end; //新写的
table1.Next;
end;
end; 窗口2
procedure TForm2.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
label1.Caption:=fm.hm;// fm 是窗口1的单元文件名
if label1.Caption='1111' then
form2.N13.Enabled:=true
else
form2.N13.Enabled:=false;end;