xorpas 4 Posted January 6, 2023 I need a way to dropdown combobox with icon and text in firemonkey like this one Share this post Link to post
havrlisan 24 Posted January 6, 2023 You can add TListBoxItem controls to TComboBox, for example: procedure TForm1.AddComboBoxItem(const AText: String; const AImageIndex: Integer); var LItem: TListBoxItem; begin TComboBox1.BeginUpdate; LItem := TListBoxItem.Create(TComboBox1); LItem.Parent := TComboBox1; LItem.Images := TImageList1; LItem.ImageIndex := AImageIndex; LItem.Text := AText; TComboBox1.EndUpdate; end; TComboBox will use these exactly the same if you were to put strings in TComboBox.Items. LItem.Images is a property to which you assign a TImageList control, in which you can add images. By assigning LItem.ImageIndex, you will then use the image you defined at that index inside the TImageList. Another option is to define an FMX style in TStyleBook and directly put the image there, but that might be redundant for this specific scenario. Unsure of which approach is better in general, but I prefer the latter one as it is more convenient to use in multiple places. Really depends on what you need though. 1 Share this post Link to post