I'm not sure if it's possible. I wrote a code like this:
listBox1.Items.Add("There are " + countu.ToString().Trim() + " u's");
listBox1.Font = new Font("Arial", 12, FontStyle.Bold);
listBox1.ForeColor = Color.Violet;
listBox1.Items.Add("There are " + j.ToString().Trim() + " vowels");
listBox1.ForeColor = Color.Blue;
When I executed this code, the color of the texts were blue. I would like to have it first "violet" and then the next line of code blue. Is it possible?
Cheers
You could create an owner-drawn listbox as described in MSDN here:
ObjectListView , though it's not exactly a ListBox
, allows to do that. If you want ListBox
only, see this .
仅当您自己绘制所有内容(所有者绘制)时才有可能。
Try using listBox1.Items[currentItem].Attributes.CssStyle to set the color of each item on a granular level.
e: whoops, missed the windows-forms tag. my bad.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.