首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

如何在pictureBox下画画

2012-06-30 
怎么在pictureBox上画画C# codeprivate void Form1_Load(object sender, EventArgs e){Graphics g pictu

怎么在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);        } 

热点排行