不用createGraphics()而是直接设置背景就OK了Bitmap myImage = new Bitmap(pictureBox1.Width,pictureBox1.Height);Graphics g = Graphics.FromImage(myImage); g.DrawRectangle(Pens.Red,5,5,400,400); //画矩形pictureBox1.Image=myImage;
调试欢乐多
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
Graphics g = CreateGraphics();
g.DrawRectangle(````````);
}
pictureBox1.Image=null;
就可以了