读书人

如何在pictureBox下画画

发布时间: 2012-06-30 17:20:12 作者: rapoo

怎么在pictureBox上画画

C# code
        private void Form1_Load(object sender, EventArgs e)        {            Graphics g = pictureBox1.CreateGraphics();            g.DrawLine(new Pen(Color.White, 10), 0, 0, 111, 111);        }

C# code
        private void Form1_Paint(object sender, PaintEventArgs e)        {            Graphics g = pictureBox1.CreateGraphics();            g.DrawLine(new Pen(Color.White, 10), 0, 0, 111, 111);        }

试了都不行那

[解决办法]
不要用CreateGraphics,而是在PictureBox的Paint事件内直接画
C# code
private void pictureBox1_Paint(object sender, PaintEventArgs e)        {            e.Graphics.DrawLine(new Pen(Color.White, 10), 0, 0, 111, 111);        } 

读书人网 >C#

热点推荐