//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "NxCollection"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
// 1. Add root item

        NxPathControl1->Items->AddChild(NULL);

// 2. Set properties of 1st item in Items array

        NxPathControl1->Items->Item[0]->Text = "Music";
        NxPathControl1->Items->Item[0]->ImageIndex = 0;

// 3. Add new root item and assign reference to PicturesItem variable

        TNxPathNode *PicturesItem = (TNxPathNode*)NxPathControl1->Items->AddChild(NULL);

        PicturesItem->Text = "Pictures";
        PicturesItem->ImageIndex = 1;

        Button2->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
// 1. Add new child item inside 1st item inside Items array
        NxPathControl1->Items->AddChild(NxPathControl1->Items->Item[0])->Text = "Genres";

// 2. Manually create item's object and then add it into array
        TNxPathNode *DecadesItem = new TNxPathNode();

        DecadesItem->Text = "Decades";
        NxPathControl1->Items->AddItem(NxPathControl1->Items->Item[0], DecadesItem);
}
//---------------------------------------------------------------------------

