Click here to Skip to main content
12,632,477 members (33,539 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ MFC
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 3-Sep-12 21:41pm
Updated 3-Sep-12 23:11pm
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

try changing the color using:

//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");
    }
  Permalink  
Comments
Joan Murt 4-Sep-12 4:15am
   
MFC & C++?
rabhsaini 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161208.2 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100