unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
procedure FormCreate(Sender: TObject);
procedure FormClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
RootNode, ChildNode, SubChildNode: TTreeNode;
procedure TForm1.FormCreate(Sender: TObject);
begin
RootNode:=TreeView1.Items.AddFirst(nil, 'Root');
ChildNode:=RootNode.Owner.AddChildObject(RootNode, 'Child', nil);
SubChildNode:=RootNode.Owner.AddChildObject(ChildNode, 'SubChild', nil);
RootNode.Expand(True);
end;
procedure TForm1.FormClick(Sender: TObject);
begin
if ChildNode.Count>0 then
ChildNode.Item[0].Delete
else
ChildNode.HasChildren:=True;
end;
end.