List box text colour
it is possible to lines in a listbox have a diffeent colour. I want valid data to be black and invalid data to be red.
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Raja KrishnamurthyRank #3,615 · 403 reputationPosted Apr 13, 2011, 12:28 PM EDT
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/b145eecc-9ee2-47b7-8e45-0bf32396473d
HTH
Richard Brennan89 reputationPosted Apr 13, 2011, 3:15 PM EDT
Soft CornerRank #1,221 · 1.5K reputationPosted Apr 13, 2011, 9:58 PM EDT
I can do this in ListView control, try this :
public WinForm()
{
InitializeComponent();
listView1.View = View.List;
addValid();
addInvalid();
}
private void addValid()
{
for (int i = 0; i < 3; i++)
{
listView1.Items.Add("Valid "+ i.ToString());
listView1.Items[i].ForeColor= Color.Blue;
}
}
private void addInvalid()
{
for (int i = 3; i < 6; i++)
{
listView1.Items.Add("Invalid " + i.ToString());
listView1.Items[i].ForeColor= Color.Red;
}
}
Suthish NairRank #92 · 22.8K reputationPosted Apr 14, 2011, 11:19 AM EDT