How can I change the color of the selected item in a listbox?

How can I change the color of the selected item in a listbox?

Post by S2FyZW4gR3 » Fri, 01 Jul 2005 05:34:02


I'm using a standard server side ASP.Net listbox control on a web form.
The page is basically various shades of green. The listbox itself has a pale
green background and forest green text and a forest green border. However,
when you move the cursor from one item to the next within the listbox or you
click on an item in the listbox to select it, the background turns to the
standard windows dark blue with white letters. Well, that looks ugly. I
want the background to turn 'forest green' and the characters to turn 'wheat'
when the item is selected. I already have one app in blue and this one needs
to be slightly different in design, so I"ve chosen to use shades of green.

How do I do this without having to completely re-create the whole
listbox control? I really don't think I should have to do that just to
control the color of the selected item. The same goes for the listbox
scrollbars, by the way.

If there are attributes for setting these colors or 'styles' that I'm
unaware of, any code samples would be greatly appreciated.

If there's a free replacement listbox control somewhere that I can
download that just allows the style of the selected item(s) in a listbox to
be modified, I'd appreciate knowing about that. Or, if there is a free or
lowcost one available that also has the capability to define the scrollbar
colors as well as the selected item color within the control, that would be
very cool! But only if it's free or very low cost (under $30)

Please let me know. I seem to be finding this question in a lot of
forums without good answers! I'm surprised Microsoft hasn't fixed this yet.

Karen Grube