当前位置:编程学习 > C#/ASP.NET >>

Windows mobile怎么使用CreateGraphics

Graphics gp=控件名.CreateGraphics();编译的时候没问题,我是在MouseDown中加的,调试一点击就报错,如下:未处理"System.NotSupportedException"类型的异常出现在System.Darwing.dll中。 --------------------编程问答-------------------- 没用过帮顶吧。 --------------------编程问答-------------------- 不是这个的问题,可能是其他的,比如ImageAttributes的问题。可能出错的相关的函数贴出来看看。wince我非常熟悉,但不看到代码有点不记得,我以前也遇到过很多次类似问题,但看了你代码才能记得起来。 --------------------编程问答-------------------- 大牛们帮忙看看吧,谢谢啦,调试到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();
        }
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,