解决方案 »

  1.   

    你自己画的东西要放到OnPaint事件中,这样在重绘时才不会丢失,设置image后,picturebox在的onpaint中会自动DrawImage(this.image, rect); 源码如下,看最后面那几句代码protected override void OnPaint(PaintEventArgs pe)
    {
        if (this.pictureBoxState[0x20])
        {
            try
            {
                if (this.WaitOnLoad)
                {
                    this.Load();
                }
                else
                {
                    this.LoadAsync();
                }
            }
            catch (Exception exception)
            {
                if (ClientUtils.IsCriticalException(exception))
                {
                    throw;
                }
                this.image = this.ErrorImage;
            }
        }
        if (this.image != null)
        {
            this.Animate();
            ImageAnimator.UpdateFrames();
            Rectangle rect = (this.imageInstallationType == ImageInstallationType.ErrorOrInitial) ? this.ImageRectangleFromSizeMode(PictureBoxSizeMode.CenterImage) : this.ImageRectangle;
            pe.Graphics.DrawImage(this.image, rect);
        }
        base.OnPaint(pe);

      

  2.   

    基本上就是你自己画线不一定都在系统重绘ui之后执行。放在onpaint里是一个办法,还有个简单办法把你画好的image作为backgroundimage赋值给窗体……那么系统就会把你画的内容作为窗体的一部分自动重绘了