Y
yfli
Unregistered / Unconfirmed
GUEST, unregistred user!
程序如下,为何我无发读出正确Treeview中Data的数据
请告诉我,我的程序错在那里。
写入程序:
procedure TForm1.Button1Click(Sender: TObject);
var
MyData:Integer;
MyPTRInteger;
begin
MyData := StrToInt(Edit1.Text);
MyPTR:= @MyData;
TreeView1.Items.AddObject(nil,'Item',MyPTR);
Dispose(MyPTR);
end;
读出程序:
procedure TForm1.Button2Click(Sender: TObject);
var
MyPTRInteger;
begin
if TreeView1.Selected <> nil then
begin
MyPTR := TreeView1.Selected.Data;
ShowMessage(Inttostr(MyPTR^));
Dispose(MyPTR);
end;
请告诉我,我的程序错在那里。
写入程序:
procedure TForm1.Button1Click(Sender: TObject);
var
MyData:Integer;
MyPTRInteger;
begin
MyData := StrToInt(Edit1.Text);
MyPTR:= @MyData;
TreeView1.Items.AddObject(nil,'Item',MyPTR);
Dispose(MyPTR);
end;
读出程序:
procedure TForm1.Button2Click(Sender: TObject);
var
MyPTRInteger;
begin
if TreeView1.Selected <> nil then
begin
MyPTR := TreeView1.Selected.Data;
ShowMessage(Inttostr(MyPTR^));
Dispose(MyPTR);
end;