How to change the color of the selected item in a web listbox cont




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

Eliyahu Goldin


1. Make Css classes for selected items with the colors of your choice.
2. Try to find out what DHTML objects your list is rendered as. use
browser's "View source" option for that.
3. Setup client-side onclick events that will change the item styles to the
classes prepared on stage 1.

It does take a bit of researching and efforts.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads