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

#include <vcl.h>
#pragma hdrstop

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

// BeginExample: TComboBoxEx
// Class: ComCtrls.TComboBoxEx
// Class: ComCtrls.TComboExItems
// Method: ComCtrls.TComboExItems.AddItem

// BeginCode
/*
This is a very simple example showing how to create a comboBoxEx, add
to it some items and images, indenting the items and getting the
selected value.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//comboBoxEx initialization
combEx = new TComboBoxEx(this);
combEx->Parent = this;

//visual options
combEx->Align = TAlign::alLeft;
combEx->DoubleBuffered = true;

//adding image content
TCustomImageList* myImages = new TCustomImageList(16,16);
Graphics::TBitmap* image = new Graphics::TBitmap();

//for this examples the images are 50x50 pixels
image->LoadFromFile("..\\little_logo_16.bmp");
myImages->Add(image, NULL);
image->LoadFromFile("..\\littleB_16.bmp");
myImages->Add(image, NULL);
image->LoadFromFile("..\\little_sun_16.bmp");
myImages->Add(image, NULL);

combEx->Images = myImages;

//adding the items with the corresponding indexes to the images
//plus some indentations
combEx->ItemsEx->AddItem("firstChoiceEx", 0, 0, 0, 0, NULL);
combEx->ItemsEx->AddItem("secondChoiceEx", 1, 1, 1, 1, NULL);
combEx->ItemsEx->AddItem("thirdChoiceEx", 2, 2, 2, 2, NULL);

   //setting the default value
  combEx->ItemIndex = 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  MessageDlg("Selected text: " + combEx->Text,
  			 mtInformation, TMsgDlgButtons() << mbOK, 0);
}
// EndCode
// EndExample: TComboBoxEx
  //---------------------------------------------------------------------------
