unit TreeViewToListBox;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: TreeViewToListBox
// Method: ComCtrls.TTreeNodes.GetFirstNode
// Method: ComCtrls.TTreeNode.GetNext

// BeginCode
{
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;
// EndCode
// EndExample: TreeViewToListBox
end.
