How to change the Selected Item's forecolor in ListBox-URGENT

Discussion in 'ASP .Net Web Controls' started by Divya, Jul 26, 2005.

  1. Divya

    Divya Guest

    Hi,


    When a listbox's Enabled property is set to false the control is greyed
    out to show that the control is
    disabled/read-only. However, when the control is disabled
    and an item is selected you can barely see the text that
    is selected . Is it possible to change
    the SelectedItem's forecolor to perhaps white and leave
    the unselected ones grey when the control's Enabled
    property is set to false.


    Thanks,
    Divya
     
    Divya, Jul 26, 2005
    #1
    1. Advertisements

  2. Divya

    Marcel Guest

    You can use something like:

    <option style="background-color:red">Selected</option>

    Marcel van Eijkel
    (www.vaneijkel.com)
     
    Marcel, Aug 1, 2005
    #2
    1. Advertisements

  3. I do belive it is possible, though I haven't tried it :) Something
    like this code should work, though of course you will have to determine
    when to set it, and replace with your own listbox :)

    ListItem itm = myList.Items[ myList.SelectedIndex ];
    itm.Attributes.CssStyle.Add("color:white");

    - Andrew
    <no website to plug>
    ps. post useful answers, M. this is a webcontrols forum.
     
    Andrew Backer, Aug 1, 2005
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.