弄错了,是这段
procedure TForm_type_set.cxbtn_addcClick(Sender: TObject);
var
l:Integer;
node,mnode:TTreeNode;
id,pid,name:string;
begin
l:=cxtv.Items.Count;
node:=cxtv.Selected;
if (l=0) or (node=nil) then begin
Application.MessageBox('请选择一个父类!','提示!');
end else begin
mnode:=cxtv.Items.AddChild(cxtv.Selected,'newItem');
id:=IntToStr(mnode.Index);
pid:=StringOfChar(' ',mnode.Level)+inttostr(mnode.Parent.Index);
name:=mnode.Text;
cdm.CDS_Cata.AppendRecord([id,name,pid]);
end;
end;