Hi guys,

I am trying to change color of the existing items in my listbox. Can somebody please help?

You have to put some of your code here, you have to show what you ve done so far, after that I am pretty sure that someone will help you out with your problem.

Below method works fine for adding new items to the listbox but not in case when I am trying to change the forecolor of an existing item in a listbox.

    private void Form1_Load(object sender, EventArgs e)
    {
        listBox1.Items.Add("First");
        listBox1.Items.Add("Second");
        listBox1.DrawMode = DrawMode.OwnerDrawFixed;
        listBox1.DrawItem += new DrawItemEventHandler(listBox1_DrawItem);
    }

    void listBox1_DrawItem(object sender, DrawItemEventArgs e)
    {
        e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, Brushes.Red, e.Bounds);

    }

Hope this clarifies my approach?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.