Jump to content
Registration disabled at the moment Read more... ×
softtouch

TComboBoxEx icon in editbox?

Recommended Posts

I have a TComboBoxEx with items in it. Each item has an icon assigned, so far so good.

When I click into the editbox to enter a new item name, there is no icon of course, but instead a weird space to the left (see attached image).

 

testing_2024-04-17_09-11-19.png.2f8ad58cc8e7a75a00879992e8288613.png

 

Is there any way to have a default icon displayed in the editbox of the TComboBoxEx?

Share this post


Link to post

EDIT: This is for TComboBox, I never used TComboBoxEx and I don't know if that I suggest is working with that component.

 

You can use OnDrawItem to draw what you want this is an example that draw a flag (form an array of pngimages), you have to see if you can also use this method for the Edit position:

 

//FlagListPNG is a list of pngimages
//NameLangLisTXT is a list of string (name of the languages)
//You must adapt of course at your use

procedure TLanguageSelect.ComboBox1DrawItem(Control: TWinControl;
  Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
  try
    TComboBox(Control).Canvas.Draw(Rect.Left + 8, Rect.Top + (Rect.Height div 2 - FlagListPNG[Index].Height div 2), FlagListPNG[Index]);
    TComboBox(Control).Canvas.TextOut(Rect.Left + 8 + FlagListPNG[Index].Width + 8, Rect.Top, NameLangListTXT[Index]+'        ');
  except
    TComboBox(Control).Canvas.TextOut(Rect.Left + 10, Rect.Top, NameLangListTXT[Index]);
  end;
end;

image.thumb.png.b47a6e58c7df18a51c6ee683a0434d1f.png

Edited by DelphiUdIT

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×