C# 我想使用GDI+在picturebox中画图,用按钮触发它。就是按一个按钮之后画出对应的图画,怎么弄?

RT

在按钮里picturebox.refresh();
picturebox有一个事件叫做Paint,画图在Paint里就可以了

private void picBxSketch_Paint(object sender, PaintEventArgs e)
{
int distance = 40;

Pen linePen = new Pen(Color.Red);
for (int i = 1; i <= 4; i++) {
//初始的四条横线,横线建的间距大一些
e.Graphics.DrawLine(linePen, new Point(85, (distance + 10) * i + 30), new Point(240, (distance + 10) * i + 30));//横线
e.Graphics.DrawLine(linePen, new Point(distance * i + 65, 60), new Point(distance * i + 65, 250));//竖线
}}

这是一个画线的代码,还有很多e.Graphics的方法,如果要旋转的话,要有很多要注意的地方
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-04-29
我觉得这件事可以活用委托。。。
第2个回答  2011-04-29
还可以这样画
在button的代码中
Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle);
然后 g.DrawImage(,,,);
相似回答