if ((j < pinteger(TreeView1.Items.Data)^) and
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ try this
(pinteger(TreeView1.Items.Data)^ < 9)) then
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ and this
j:=pinteger(TreeView1.Items.Data)^;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
end;
j:=j+1;
new(id);
^^^^^^^^ what's id???? var id: PInteger?
id^:=j;
ParentNode:=TreeView1.items.AddChildObject(nil,InsertDlg.InputEdit.Text,
id^);
^^^
ParentNode.ImageIndex:=13;
ParentNode.SelectedIndex:=13;
//添加P小计、K小计、合计
AddChildItem(ParentNode,'P小计',j*100+97,16,16,Table1,'0');
AddChildItem(ParentNode,'K小计',j*100+98,16,16,Table1,'0');
AddChildItem(ParentNode,'合计',j*100+99,16,16,Table1,'0');
end;
end
删除程序段:
if MessageBox(handle,'是否要删除此线路?','警告',MB_YESNO+MB_ICONWARNING+MB_DEFBUTTON2)=IDYes then
begin
if (TreeView1.Selected).parent=nil then
Table1.locate('Line;Units',VarArrayof([(TreeView1.Selected).text,'']),[])
else Table1.locate('Line;Units',VarArrayof([(TreeView1.Selected).text,(TreeView1.Selected).parent.text]),[lopartialKey]);
Table1.Delete;
TreeView1.Selected.Delete;
^^^^^^^^^^^^^^^^^^^^^^^^^^^ 这句和下一句顺序错了?
treeview1.selected.delete了(所有相关内
存已经释放了), 怎么还能找到
treeview1.selected.data?. 到此处应该
出现错误了.
dispose(TreeView1.Selected.data);
TreeView1.Selected.data:=nil;
end;
而且您用treeview.selected.delete只是释放了该node的占用内存. treeview中还
有个nil节点, 所以treeview.items.count不会变.
建议用treeview1.items.delete(treeview1.selected)比较好