unit TTreeSelected;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: TTreeSelected
// Property: ComCtrls.TCustomTreeView.Selected
// Property: ComCtrls.TListItems.Item

// BeginCode
{
The following code uses Item to add the labels of all child
nodes of the selected node to a list box when a button is
clicked.  This example requires a button, a listbox, and a
populated treeview.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  I : Integer;
begin
  for I := 0 to (TreeView1.Selected.Count - 1) do
    ListBox1.Items.Add(TreeView1.Selected.Item[I].Text);
end;
// EndCode
// EndExample: TTreeSelected
end.

