private void Form1_Paint(object sender, PaintEventArgs e)
{
bmp = new Bitmap(ClientSize.Width, ClientSize.Height, e.Graphics);
Graphics bmpgraphics = Graphics.FromImage(bmp);
for (int i = 0; i <= 13; i++)
{
bmpgraphics.DrawEllipse(new Pen(Color.FromName(colours[i]), 2),
ballarray[i, 1], ballarray[i, 2], 50, 50);
}
e.Graphics.DrawImageUnscaled(bmp, 0, 0);
//Draw ellipse acording to mouse coords.根据鼠标坐标画图
e.Graphics.DrawEllipse(new Pen(Color.Red), g1, g2, 50, 50);
bmpgraphics.Dispose();
bmp.Dispose();
}
(这只是代码其中一部分)
标红位置调试:键不能为null,关键字:key
不清楚怎么修改
{
bmp = new Bitmap(ClientSize.Width, ClientSize.Height, e.Graphics);
Graphics bmpgraphics = Graphics.FromImage(bmp);
for (int i = 0; i <= 13; i++)
{
bmpgraphics.DrawEllipse(new Pen(Color.FromName(colours[i]), 2),
ballarray[i, 1], ballarray[i, 2], 50, 50);
}
e.Graphics.DrawImageUnscaled(bmp, 0, 0);
//Draw ellipse acording to mouse coords.根据鼠标坐标画图
e.Graphics.DrawEllipse(new Pen(Color.Red), g1, g2, 50, 50);
bmpgraphics.Dispose();
bmp.Dispose();
}
(这只是代码其中一部分)
标红位置调试:键不能为null,关键字:key
不清楚怎么修改
解决方案
50
100%是原因是colours[i]这个是null
50
colors[i]是null吧?本人跟踪下,很简单的。