S
sun2003
Unregistered / Unconfirmed
GUEST, unregistred user!
unit URecorder;
interface
type
PNodeData=^TNodeData;
TNodeData=record
NodeId:integer;
end;
implementation
end.
Public
TmpNodeDataNodeData;
procedure TFmMain.FormShow(Sender: TObject);
begin
inherited;
with adodataset2 do
if active=false then open;
with adodataset1 do
if active=false then open;
showtv;
end;
//procedure showtv
treeview1.Items.Clear;
rootnode:=treeview1.Items.Add(nil,'信息');
with ADODataSet1 do
begin
Open;first;
new(TmpNodeData);
while not eof do
begin
TmpNodeData^.NodeId:=fieldbyname('省份id').AsInteger;
Treeview1.Items.AddChild(rootnode,fieldbyname('省份名称').AsString);
rootnode.Data:=TmpNodeData;
next;
end;
close;
end;
procedure TFmMain.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
inherited;
treeview1.Selected.SelectedIndex:=1;
if treeview1.Selected<>nil then
label1.Caption:=inttostr(pnodedata(treeview1.Selected.Data)^.NodeId);
//程序一开始运行正常,当按下TreeView1中的节点时却出错“Acess Violation
at address 004CCCAC in module 'a.exe'”,请指教。
end;
interface
type
PNodeData=^TNodeData;
TNodeData=record
NodeId:integer;
end;
implementation
end.
Public
TmpNodeDataNodeData;
procedure TFmMain.FormShow(Sender: TObject);
begin
inherited;
with adodataset2 do
if active=false then open;
with adodataset1 do
if active=false then open;
showtv;
end;
//procedure showtv
treeview1.Items.Clear;
rootnode:=treeview1.Items.Add(nil,'信息');
with ADODataSet1 do
begin
Open;first;
new(TmpNodeData);
while not eof do
begin
TmpNodeData^.NodeId:=fieldbyname('省份id').AsInteger;
Treeview1.Items.AddChild(rootnode,fieldbyname('省份名称').AsString);
rootnode.Data:=TmpNodeData;
next;
end;
close;
end;
procedure TFmMain.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
inherited;
treeview1.Selected.SelectedIndex:=1;
if treeview1.Selected<>nil then
label1.Caption:=inttostr(pnodedata(treeview1.Selected.Data)^.NodeId);
//程序一开始运行正常,当按下TreeView1中的节点时却出错“Acess Violation
at address 004CCCAC in module 'a.exe'”,请指教。
end;