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.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Apr 14, 2011, 3:19 PM
Soft CornerPosted Apr 14, 2011, 1:58 AM
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;
}
}
Richard BrennanPosted Apr 13, 2011, 7:15 PM
Raja KrishnamurthyPosted Apr 13, 2011, 4:28 PM
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/b145eecc-9ee2-47b7-8e45-0bf32396473d
HTH