非常感谢.
如果参数很多,太麻烦的话,可以这样。
绘图的时候,把图形绘制到picture中,把picture放在窗体上,这样图形始终在内存中保留。无论如何切换窗口,图形都不会消失。
具体绘图方法:
引用如下命名空间:
using System.Drawing;
using System.Drawing.Imaging;
申明变量:
private Image theImage;//要绘图的图片对象
private Graphics ig; //在图片上绘图的Graphics对象
private System.Windows.Forms.PictureBox MyPicBox;//窗体上的picturebox控件
theImage=new Bitmap(600,800);//宽,高
ig=Graphics.FromImage(theImage);
ig.Clear(Color.White); //底色为白色
MyPicBox.Image=theImage;//将绘制的image放在picturebox中
Pen drawPen = new Pen ( Color . Blue , 2 ) ; //画笔工具
ig.DrawRectangle(drawPen,20,20,40,40);//绘制一个矩形区域