unit Main;

interface

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

type
  TMainForm = class(TForm)
    ImageList1: TImageList;
    Panel1: TPanel;
    imgKONIEC: TImage;
    TreeView: TTreeView;
    procedure FormCreate(Sender: TObject);
    procedure TreeViewClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure imgKONIECClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation
{$R *.dfm}
{------------------------------------------------------------------------------}
procedure TMainForm.FormCreate(Sender: TObject);
begin
	TreeView.Align := alLeft;
end;

procedure TMainForm.FormShow(Sender: TObject);
var
   node  : TTreeNode;
   node1 : TTreeNode;

begin

   node  := TreeView.Items.Add(Nil, 'Jeden');
   node.ImageIndex  := 0;
   node1 := TreeView.Items.AddChild(node, '1-1');
   node1.ImageIndex := 1;

   node  := TreeView.Items.Add(Nil, 'Dwa');
   node.ImageIndex  := 2;
   node1 := TreeView.Items.AddChild(node, '2-1');
   node1.ImageIndex := 3;
   node1 := TreeView.Items.AddChild(node, '2-2');
   node.ImageIndex  := 4;

   node  := TreeView.Items.Add(Nil, 'Trzy');
   node.ImageIndex  := 5;
   node1 := TreeView.Items.AddChild(node, '3-1');
   node1.ImageIndex := 6;
   node1 := TreeView.Items.AddChild(node, '3-2');
   node1.ImageIndex := 7;
   node1 := TreeView.Items.AddChild(node, '3-3');
   node1.ImageIndex := 8;

   node  := TreeView.Items.Add(Nil, 'Cztery');
   node.ImageIndex  := 9;
   node1 := TreeView.Items.AddChild(node, '4-1');
   node1.ImageIndex := 10;
   node1 := TreeView.Items.AddChild(node, '4-2');
   node1.ImageIndex := 11;
   node1 := TreeView.Items.AddChild(node, '4-3');
   node1.ImageIndex := 12;
   node1 := TreeView.Items.AddChild(node, '4-4');
   node1.ImageIndex := 13;

   node  := TreeView.Items.Add(Nil, 'Piêæ');
   node.ImageIndex  := 14;
   node1 := TreeView.Items.AddChild(node, '5-1');
   node1.ImageIndex := 15;
   node1 := TreeView.Items.AddChild(node, '5-2');
   node1.ImageIndex := 16;
   node1 := TreeView.Items.AddChild(node, '5-3');
   node1.ImageIndex := 17;
   node1 := TreeView.Items.AddChild(node, '5-4');
   node1.ImageIndex := 18;
   
   TreeView.AutoExpand := true;
end;

procedure TMainForm.imgKONIECClick(Sender: TObject);
begin
	Close();
end;

procedure TMainForm.TreeViewClick(Sender: TObject);
var
	nazwa  : String;
   
begin
	nazwa := TreeView.Selected.Text;
   ShowMessage(nazwa);
end;

end.

