求大神指点 哪里错了?
private void lblMode_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
int xPos, yPos;
xPos = e.X / 31;
yPos = e.Y / 31;
struArr[xPos, yPos] = !struArr[xPos, yPos];
bool b = struArr[xPos, yPos];
Graphics gp = lblMode.CreateGraphics();
SolidBrush s = new SolidBrush(b ? blockColor : Color.Black);
gp.FillRectangle(s, 31 * xPos + 1, 31 * yPos + 1, 30, 30);
gp.Dispose;
}
------解决方案--------------------
gp.Dispose 没括号,
e.X / 31 了再 31 * xPos 两者不一定相等,最好是用 e.X ,e.Y 。