RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNode.GetPrevChild Method

Returns the previous child node before Value.

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

Call GetPrevChild to locate the previous node in the list of immediate children of the tree view node. If the calling node has no children or there is no node before Value, GetPrevChild 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) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!