CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Posts
    4

    Colored background dropdownlist in combobox

    Hello, i have a problem with coloring background in combobox..


    As you can see.. background is colored after mouse move on text.. what i should to do to get automatic colored background?

  2. #2
    Join Date
    Oct 2013
    Posts
    16

    Re: Colored background dropdownlist in combobox

    This works fine for me
    Code:
    void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
            {
                if (e.Index < 0) return;
    
                if (comboBox1.Items[e.Index].ToString().Contains(".99."))
                    e.Graphics.FillRectangle(new SolidBrush(Color.Red), (Rectangle)e.Bounds);
    
                e.Graphics.DrawString(comboBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(comboBox1.ForeColor), new Point(e.Bounds.X, e.Bounds.Y));
            }
    Probably your error is that you don't use the item index

  3. #3
    Join Date
    Oct 2013
    Posts
    4

    Re: Colored background dropdownlist in combobox

    Thanks a lot, its working fine now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured