Click here to Skip to main content
15,851,242 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
System.Windows.Forms.Label lbl = new System.Windows.Forms.Label();
lbl.ForeColor = System.Drawing.Color.Blue;

string txt = " " + "==" + " " + "Folders title:" + " " + sub + " " +  siteColName + " ";
var display= lbl.Text = txt.ToString();
listboxLogging.Items.Add( display + Environment.NewLine);
Updated 12-Feb-15 2:37am

1 solution

You are not putting the label "into" the listbox, you are putting the text into the list box.

Text does not have a concept of colour.

It's actually quite difficult to set the colour of items in a listbox - you could use a ListView instead. Once you have added the item you can change the properties of that item (NB of the item, not the "text")

Or if you really want to use a Listbox you can "draw" the colour yourself - see some suggestions here[^]
Share this answer

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