anchor.diff:      n2.AppendText('Child 1').AppendText('Child 2');
       n2.Collapsed := False;
     end;
  +
  +  TreeNodeChanged(nil);
  +end;
  +
  +procedure TMainForm.btnSourceClicked(Sender: TObject);
  +begin
  +  FSrcNode := tree.Selection;
  +  if Assigned(FSrcNode) then
  +    lblSource.Text := FSrcNode.Text
  +  else
  +    lblSource.Text := '--';
  +end;
  +
  +procedure TMainForm.btnDestinationClicked(Sender: TObject);
  +begin
  +  FDestNode := tree.Selection;
  +  if Assigned(FDestNode) then
  +    lblDestination.Text := FDestNode.Text
  +  else
  +    lblDestination.Text := '--';
  +end;
  +
  +procedure TMainForm.btnMoveToClicked(Sender: TObject);
  +var
  +  i: integer;
  +begin
  +  if FSrcNode = FDestNode then
  +  begin
  +    ShowMessage('Source and Destination may not be the same');
  +    exit;
  +  end;
  +  i := cbMoveToTypes.FocusItem;
  +  FSrcNode.MoveTo(FDestnode, TfpgNodeAttachMode(i)); // This cast is a hack! Do not do this in real-world apps!!
  +  tree.FullExpand;
  +  tree.Invalidate;
  +  // reset values
  +  FSrcNode := nil;
  +  FDestnode := nil;
  +  lblSource.Text := '--';
  +  lblDestination.Text := '--';
  +
  +  TreeNodeChanged(nil);
  +end;
  +
  +procedure TMainForm.TestButtonClicked(Sender: TObject);
  +var
  +  n: TfpgTreeNode;
  +begin
  +  n := Tree.Selection;
  +  n.Parent.Remove(n);
  +  n.Free;
  +  Tree.Invalidate;
   end;
   
   procedure TMainForm.cbShowImagesChange(Sender: TObject);
  
positive.code:   fpg_tree,
    fpg_checkbox,
    fpg_button,
    fpg_imagelist;
  
  type
  
    TMainForm = class(TfpgForm)
    private
      {@VFD_HEAD_BEGIN: MainForm}
      tree: TfpgTreeView;
      cbShowImages: TfpgCheckBox;
      cbIndentNode: TfpgCheckBox;
      btnClear: TfpgButton;
      {@VFD_HEAD_END: MainForm}
      FImagelist: TfpgImageList;
      procedure   cbShowImagesChange(Sender: TObject);
      procedure   cbIndentNodeChange(Sender: TObject);
      procedure   btnClearClicked(Sender: TObject);
      procedure   PopulateTree;
    public
      constructor Create(AOwner: TComponent); override;
      destructor  Destroy; override;
  
negative.code:   begin
      Name := 'btnClear';
      SetPosition(8, 222, 144, 23);
      Anchors := [anLeft,anBottom];
      Text := 'Clear Selected Node';
      FontDesc := '#Label1';
      Hint := '';
      ImageName := '';
      TabOrder := 3;
      OnClick := @btnClearClicked;
    end;
  
    Label1 := TfpgLabel.Create(self);
    with Label1 do
    begin
      Name := 'Label1';
      SetPosition(312, 12, 292, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    Label2 := TfpgLabel.Create(self);
    with Label2 do
    begin
      Name := 'Label2';
      SetPosition(312, 32, 288, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    Label3 := TfpgLabel.Create(self);
    with Label3 do
    begin
      Name := 'Label3';
      SetPosition(312, 52, 272, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    Label4 := TfpgLabel.Create(self);
    with Label4 do
    begin
      Name := 'Label4';
      SetPosition(312, 72, 300, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    Label5 := TfpgLabel.Create(self);
    with Label5 do
    begin
      Name := 'Label5';
      SetPosition(312, 92, 320, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    Bevel1 := TfpgBevel.Create(self);
    with Bevel1 do
    begin
      Name := 'Bevel1';
      SetPosition(312, 116, 388, 12);
      Anchors := [anLeft,anRight,anTop];
      BorderStyle := bsDouble;
      Hint := '';
      Style := bsLowered;
      Shape := bsTopLine;
    end;
  
    lblSource := TfpgLabel.Create(self);
    with lblSource do
    begin
      Name := 'lblSource';
      SetPosition(312, 160, 140, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    lblDestination := TfpgLabel.Create(self);
    with lblDestination do
    begin
      Name := 'lblDestination';
      SetPosition(464, 160, 128, 16);
      FontDesc := '#Label1';
      Hint := '';
      Text := 'Label';
    end;
  
    btnSource := TfpgButton.Create(self);
    with btnSource do
    begin
      Name := 'btnSource';
      SetPosition(312, 132, 80, 24);
      Text := 'Source';
      FontDesc := '#Label1';
      Hint := '';
      ImageName := '';
      TabOrder := 13;
      OnClick := @btnSourceClicked;
    end;
  
    btnDest := TfpgButton.Create(self);
    with btnDest do
    begin
      Name := 'btnDest';
      SetPosition(464, 132, 80, 24);
      Text := 'Destination';
      FontDesc := '#Label1';
      Hint := '';
      ImageName := '';
      TabOrder := 14;
      OnClick := @btnDestinationClicked;
    end;
  
    btnMoveTo := TfpgButton.Create(self);
    with btnMoveTo do
    begin
      Name := 'btnMoveTo';
      SetPosition(608, 132, 80, 24);
      Text := 'MoveTo';
      FontDesc := '#Label1';
      Hint := '';
      ImageName := '';
      TabOrder := 15;
      OnClick := @btnMoveToClicked;
    end;
  
    cbMoveToTypes := TfpgComboBox.Create(self);
    with cbMoveToTypes do
    begin
      Name := 'cbMoveToTypes';
      SetPosition(608, 164, 96, 22);
      FontDesc := '#List';
      Hint := '';
      Items.Add('naAdd');
      Items.Add('naAddFirst');
      Items.Add('naAddChild');
      Items.Add('naAddChildFirst');
      Items.Add('naInsert');
      TabOrder := 16;
      FocusItem := 0;
    end;
  
    Button1 := TfpgButton.Create(self);
    with Button1 do
    begin
      Name := 'Button1';
      SetPosition(472, 208, 80, 24);
      Text := 'Button';
      FontDesc := '#Label1';
      Hint := '';
      ImageName := '';
      TabOrder := 17;
      OnClick  := @TestButtonClicked;
    end;
  
    {@VFD_BODY_END: MainForm}
  