我收到错误消息:
参数无效。
从这一行:
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);
}
}
答案 0 :(得分:0)
您提供的信息太少。可能e.Bounds不是有效的矩形。 (Rectangle为0或null)。