function ItemExist(Text:string;TreeView:TTreeView):Boolean;
var
i: Integer;
begin
Result:=False;
if (Trim(Text)<>'') then
begin
for i := 0 to TreeView.Items.Count-1 do
if Trim(Text) = Trim(TreeView.Items[i].Text) then
begin
Result:=True;
Exit;
end;
end;
Result:=False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not ItemExist('Edit1.Text',TreeView1) then
TreeView1.Items.AddChild(Treeview1.Selected,'Edit1.Text');
end;