RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNode.GetNextChild Method

Returns the next child node after Value.

Pascal
function GetNextChild(Value: TTreeNode): TTreeNode;
C++
__fastcall TTreeNode GetNextChild(TTreeNode Value);

Call GetNextChild to locate the next node in the list of immediate children of the tree view node. If the calling node has no children or there is no node after Value, GetNextChild returns nil (Delphi) or NULL (C++).  

C++ Examples: 

 

/*
The following code tests to see if the currently selected
item has a sibling; if so, HasSibling will be set to true.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TTreeNode *SelNode = TreeView1->Selected;
TTreeNode *ParentNode = SelNode->Parent;
bool HasSibling = (ParentNode->GetPrevChild(SelNode) ||
                   ParentNode->GetNextChild(SelNode));
  if (HasSibling) Edit1->Text = "True";
  else Edit1->Text = "False";
}

 

Delphi Examples: 

{
The following code tests to see if the currently selected
item has a sibling; if so, HasSibling will be set to true.
} 
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;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!