不是这个的问题,可能是其他的,比如ImageAttributes的问题。可能出错的相关的函数贴出来看看。wince我非常熟悉,但不看到代码有点不记得,我以前也遇到过很多次类似问题,但看了你代码才能记得起来。

解决方案 »

  1.   

    大牛们帮忙看看吧,谢谢啦,调试到Graphics gp = lblmode.CreateGraphics();就有问题了,我用的是penal控件
            private bool[,] struArr = new bool[4, 4];
            private Color blockColor = Color.Red;        private void lblmode_Paint(object sender, PaintEventArgs e)
            {
                Graphics gp = e.Graphics;
                gp.Clear(Color.Black);
                Pen p = new Pen(Color.White);
                for (int i = 31; i < 123; i = i + 31)
                    gp.DrawLine(p, 1, i, 123, i);
                for (int i = 31; i < 123; i = i + 31)
                    gp.DrawLine(p, i, 1, i, 123);        }        private void lblmode_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button != MouseButtons)
                    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();
            }