See TImageList in the LCL reference for details.
Example with ComboBox
To use TImageList, drop an ImageList object onto the form.
All images must be the same size.
Set the height and width of the images in the Object Inspector. in this case 50px wide by 18px high.
Double-click on the ImageList icon to open the ImageList editor. Make sure that the icons show correctly when selected. If they are smaller than expected, check the size in the Object Inspector <F11>. You may have to reload the images.
For this example the images will be used in a ComboBox called cbSymbols, rather than text. (Makes translation unnecessary.)
In the FormCreate event enter:
cbSymbols.Items.Clear; For I := 0 To 5 Do cbSymbols.Items.Add(); cbSymbols.ItemIndex := 0;
This will write 6 blank entries, and select the first.
In the OnDrawItem event for cbSymbols place the following code:
Procedure TMyForm.cbSymbolsDrawItem(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState); var cnv: TCanvas; begin if not (Control is TComboBox) then Exit; cnv:=TComboBox(Control).Canvas; Imagelist1.Draw(cnv, ARect.Left+2, Arect.Top+2, index); End;
The adjustments (+2) are to centre the image in the item, if necessary.