Hi pothik05,
You need to handle the drawing for all items in the ListBox using DrawMode.OwnerDrawnFixed/Variable and the DrawItem event.
This sample uses a ListBox where one of the items in the list is the string "Two". This item will be colored Red and if selected highlighted with bold red.
private void listBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
e.DrawBackground();
Brush textBrush = SystemBrushes.ControlText;
Font drawFont = e.Font;
if(listBox1.Items[e.Index].ToString() == "Two")
{
textBrush = Brushes.Red;
if((e.State & DrawItemState.Selected) > 0)
drawFont = new Font(drawFont.FontFamily, drawFont.Size, FontStyle.Bold);
}
else if((e.State & DrawItemState.Selected) > 0)
{
textBrush = SystemBrushes.HighlightText;
}
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), drawFont, textBrush, e.Bounds);
}
Instead of calling e.DrawBackGround you could customize your own background drawing code as well. Just remember to test for DrawItemState.Selected and use SystemBrushes.Highlight as the selected background color.