GetPrevChild (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code tests whether the currently selected item has a sibling; if so, HasSibling is set to True.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  HasSibling: Boolean;
  SelNode: TTreeNode;
  ParentNode: TTreeNode;
begin
  SelNode := TreeView1.Selected;
  ParentNode := SelNode.Parent;
  HasSibling := (ParentNode.GetPrevChild(SelNode) <> nil) or
                (ParentNode.GetNextChild(SelNode) <> nil);
  if (HasSibling) then Edit1.Text := 'True'
  else Edit1.Text := 'False';
end;

Uses