RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNode.GetNext Method

Returns the next node after the calling node in the tree view.

Pascal
function GetNext: TTreeNode;
C++
__fastcall TTreeNode GetNext();

If the calling node is the last node, GetNext returns nil (Delphi) or NULL (C++). Otherwise, it returns the next node including nodes that aren't visible and child nodes. To get the next node at the same level as the calling node, use GetNextSibling. To get the next visible node, use GetNextVisible.  

C++ Examples: 

 

/*
The following example adds the Text for all items in the
tree view to the list box.  This example requires a ListBox
and a populated TreeView.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TTreeNode *CurItem = TreeView1->Items->GetFirstNode();
  while (CurItem)
  {
    ListBox1->Items->Add(CurItem->Text);
    CurItem = CurItem->GetNext();
  }

 

Delphi Examples: 

{
The following example adds the Text for all items in the
tree view to the list box.  This example requires a ListBox
and a populated TreeView.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  CurItem: TTreeNode;
begin
  CurItem := TreeView1.Items.GetFirstNode;
  while CurItem <> nil do
  begin
    ListBox1.Items.Add(CurItem.Text);
    CurItem := CurItem.GetNext;
  end;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!