Change selected item/s selected colour

For questions and postings not covered by the other forums
Posts: 8
Joined: Tue Oct 01, 2013 8:19 am

Change selected item/s selected colour

Postby » Mon Oct 07, 2013 10:34 am

Does anyone know how to change the selected item/s selected colour for listboxes and combos without affecting the listIndex and itemSelected properties?

Posts: 11
Joined: Wed Sep 22, 2010 5:22 pm

Re: Change selected item/s selected colour

Postby mjagers » Fri Nov 03, 2017 8:14 am

If the listbox item is clicked then the listIndex is set and listbox.itemSelected[listbox.listIndex] will be true.

And setting the foreColor / backColor is as simple as:
listbox.itemForeColor[listbox.listIndex] := <fore color>
listbox.itemBackColor[listbox.listIndex] := <back color>

Combobox should be similar.

Posts: 1
Joined: Fri Feb 09, 2018 10:11 pm

Re: Change selected item/s selected colour

Postby MelissaMay » Fri Feb 09, 2018 10:16 pm

You have to the element of attributes to be true. I agree with Mjagers. listbox.itemForeColor[listbox.listIndex] := <fore color> . In graphics Use owner-draw mode of the ListBox. Select your ListBox in design-mode and change DrawMode property to OwnerDrawFixed. Then attach a handler to DrawItem event and then use Graphics class's methods to draw your string in any color or font you like.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests