エラーメッセージが表示されます:
パラメータが無効です。
この行から:
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
ここに私の描画関数:
private int mouseIndex = -1;
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index == -1) return;
Brush textBrush = SystemBrushes.WindowText;
if (e.Index > -1)
{
if (e.Index == mouseIndex)
{
e.Graphics.FillRectangle(SystemBrushes.HotTrack, e.Bounds);
textBrush = SystemBrushes.HighlightText;
}
else
{
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
textBrush = SystemBrushes.HighlightText;
}
else
{
// This Line:
e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
}
}
e.Graphics.DrawString(contact.P_DISPLAYNAME,
e.Font, textBrush, e.Bounds.Left + 20, e.Bounds.Top);
}
}