一个小小的范例,在各节点加入自定义的任何信息:
type
TNodeLevel = (STATE,PROVINCE,DW,BM,USER,GC,OTHER);
PMyNodeMsg = ^TMyNodeMsg; //要加入的信息记录
TMyNodeMsg = record
Level: TNodeLevel;
UserID: string;
GCID: string;
end;
...
//建立节点的信息
var
tempNodeMsg: PMyNodeMsg;
tempNode1: TTreeNode;
begin
...
New(tempNodeMsg);
tempNodeMsg.Level:=STATE;
tempNode1:=Detail.Items.AddChildObject(nil,sNode,tempNodeMsg);
^TreeView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tempNode1.ImageIndex:=0;
tempNode1.SelectedIndex:=0;
...
end;
取信息:
procedure TZLJDMainForm.DetailChange(...)
begin
if PMyNodeMsg(Node.Data).Level=GC then
begin
CommonMsg.GCJDDJH:=PMyNodeMsg(Node.Data).GCID;
CommonMsg.GCMC:=Node.Text;
CommonMsg.CurrGCUserID:=PMyNodeMsg(Node.Data).UserID;
end
...
end;