Recent

Author Topic: TComboBox.Font.Color seems to affect text selection when used in OnChange  (Read 410 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 922
Hi,

I don't understand what is happening here. I put 2 Comboboxes on a form. In the onchange I check if the Text is already in the itemlist of the combobox. If it already occurs, I color the text. At least that was the intention. If I change the text color then the whole text is selected. See the difference between the combobox1 and 2. If I enter an "a" in combobox1, the text is immediately selected. This does not happen with combobox2. It seems that "ComboBox1.Font.Color" does something with the selection when used in the onchange event.
The automatic selection only happens when there are items in the itemlist. If the itemlist is empty, setting the font color works fine. Turning off Autoselect makes no difference. (Windows 11, Lazarus 4.6)


jamie

  • Hero Member
  • *****
  • Posts: 7774
It's a native Windows control; you don't have a lot of control over the colors.

It's possible that both combos' are using the PARENT font, maybe you can switch that off.


But the best solution would be to set the combos for Owner Draw and paint the colors yourself in the DrawItem event.

Jamie
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018