RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNodes.GetFirstNode Method

Returns the first tree node in the tree view.

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

Use the GetFirstNode method to retrieve the first node in the tree view. GetFirstNode returns the value of Item[0].  

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!