RAD Studio VCL Reference
|
Identifies the parent node of the tree node.
property Parent: TTreeNode;
__property TTreeNode Parent;
A Parent node is one level higher than the node and contains the node as a subnode.
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!
|