Mark- 39 Posted October 19 Hello, Delphi 10.2 Both TComboboxes have the same settings except for the style. I have not found a method at design time or run time, to make the box with csDropDownList style, correctly apply the color property of the control. Perhaps I am not seeing the forest for the trees. Ideas? Thanks, Mark Share this post Link to post
Remy Lebeau 1694 Posted October 19 (edited) At design-time, setting the Color property will work for csDropDownList, but at runtime that doesn't work. So instead, you have to set the Style property to csOwnerDraw... and use the OnDrawItem event to manually paint the individual list items however you want, including the ComboBox's edit area above the list, eg: procedure TMyForm.ComboBox2DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin ComboBox2.Canvas.Brush.Color := ...; ComboBox2.Canvas.Font.Color := ...; ComboBox2.Canvas.FillRect(Rect); ComboBox2.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, ComboBox2.Items[Index]); end; If you want to paint the edit area differently then the list items, you can differentiate by checking if the odComboBoxEdit flag is present in the State parameter, eg: procedure TMyForm.ComboBox2DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); begin if odComboBoxEdit in State then begin // edit area ComboBox2.Canvas.Brush.Color := ...; ComboBox2.Canvas.Font.Color := ...; end else begin // list item ComboBox2.Canvas.Brush.Color := ...; ComboBox2.Canvas.Font.Color := ...; end; ComboBox2.Canvas.FillRect(Rect); ComboBox2.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, ComboBox2.Items[Index]); end; Edited October 19 by Remy Lebeau Share this post Link to post
Mark- 39 Posted October 19 Thanks Remy. I have done that for other combos, like pen width. Found it odd it worked out of the box for csDropDown but, not for csDropDownList. Share this post Link to post