protected override void OnPaint(PaintEventArgs e)
        {
            using (BufferedGraphicsContext bufferContext = new BufferedGraphicsContext())
            {
                using (BufferedGraphics grafx = bufferContext.Allocate(e.Graphics, base.ClientRectangle))
                {
                    grafx.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    grafx.Graphics.SmoothingMode = SmoothingMode.AntiAlias;                    // 画线操作。                    grafx.Render(e.Graphics);
                }
            }           
        }
用到双缓冲,会将背景刷成黑色,如果能做到双缓冲并且透明?

解决方案 »

  1.   

    在构造函数里加上
    this.SetStyle(ControlStyles.DoubleBuffer, true); //双缓冲
    this.SetStyle(ControlStyles.UserPaint, true);
    this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
    protected override void OnPaint(PaintEventArgs e)
      {
        e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;    // 画线操作。    e.Render(e.Graphics);
      }
     
      

  2.   

    grafx.Clear(Color.White);
    背景设置成白色的 
    透明的?应该没有这种
      

  3.   

      this.SetStyle(
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.ResizeRedraw, true);            this.SetStyle(ControlStyles.DoubleBuffer, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
    加载在构造函数中。。试试,