01.
using
System;
02.
using
System.Drawing;
03.
using
System.Windows.Forms;
04.
namespace
WindowsFormsApplication1
05.
{
06.
public
partial
class
Form1 : Form
07.
{
08.
public
Form1()
09.
{
10.
InitializeComponent();
11.
}
12.
private
void
Form1_Load(
object
sender, EventArgs e)
13.
{
14.
listBox1.DrawMode = DrawMode.OwnerDrawFixed;
15.
listBox1.DrawItem +=
new
DrawItemEventHandler(listBox1_DrawItem);
16.
Controls.Add(listBox1);
17.
}
18.
private
void
listBox1_DrawItem(
object
sender,System.Windows.Forms.DrawItemEventArgs e)
19.
{
20.
e.DrawBackground();
21.
if
(listBox1.Items[e.Index].ToString() ==
"False"
)
22.
{
23.
e.Graphics.FillRectangle(Brushes.Cyan, e.Bounds);
24.
}
25.
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, Brushes.Black,
new
System.Drawing.PointF(e.Bounds.X, e.Bounds.Y));
26.
e.DrawFocusRectangle();
27.
}
28.
}
29.
}