Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to achieve ,on list box selection(selected text background color) to show Default color or user defined color in transparent list box in MFC,C++ ?
Posted
Updated 3-Sep-12 22:11pm
v3

1 solution

try changing the color using:

C#
//lbDemo is a ListBox control.
    protected void lbDemo_SelectedIndexChanged(object sender, EventArgs e)
    {
        setItem(lbDemo, lbDemo.SelectedIndex);
    }

    void setItem(ListBox lb,int SelectedIndex)
    {
        foreach (ListItem li in lb.Items)
        {
            li.Attributes.Add("style", "color:black");
        }
        lb.Items[SelectedIndex].Attributes.Add("style", "color:blue");
    }
 
Share this answer
 
Comments
Joan M 4-Sep-12 4:15am    
MFC & C++?
SaurabSaini 4-Sep-12 4:29am    
Could you please suggest the same for tranparent list box using MFC?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900