CreateGraphics().Draw...绘图消失的解决办法

用this.CreateGraphics().DrawString()方法或者其它绘图方法在控件上绘制自己想要的东西,总是会消失,refresh时会消失?

这样总不会消失了

private void button2_Click(object sender, EventArgs e)
{
            Bitmap bmp = new Bitmap(this.pictureBox1.ClientRectangle.Width, this.pictureBox1.ClientRectangle.Height);
            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.Black);
            g.DrawRectangle(new Pen(Color.Red), 10, 10, 40, 20);
            g.Dispose();
            this.pictureBox1.Image = bmp;
}



参考资料:  http://zhidao.baidu.com/question/293022598.html   aaasuper的回答



你可能感兴趣的:(CreateGraphics().Draw...绘图消失的解决办法)