1、在内存中建立一块“虚拟画布”:

Bitmap bmp = new Bitmap(600, 600);

  2、获取这块内存画布的Graphics引用:

Graphics g = Graphics.FromImage(bmp);

  3、在这块内存画布上绘图:

g.FillEllipse(brush, i * 10, j * 10, 10, 10);

  4、将内存画布画到窗口中

this.CreateGraphics().DrawImage(bmp, 0, 0);

还有的方式
在构造函数中加如下代码

代码一:
      SetStyle(ControlStyles.UserPaint, true);
      SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
      SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲

代码二:
   this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
   this.UpdateStyles();
转载自:http://www.cppblog.com/cannon317/archive/2006/11/16/15265.html

相关文章:

  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-01-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-02-07
  • 2022-12-23
  • 2021-08-14
  • 2021-08-19
相关资源
相似解决方案