代码:
                Graphics g = this.pictureBox1.CreateGraphics();
                g.DrawLine(Pens.Black, startPoint, endPoint);
问题是:
                谁能帮忙把g绘制的直线保存入pictureBox1的Image中?
                pictureBox1中已经有先前绘制的直线了,所以不能用new的方式。
                希望谁能在上两行代码后面补充几行,完成把g新绘制的直线保存入pictureBox1的Image中。

解决方案 »

  1.   

    this.pictureBox1.CreateGraphics(); 错了
    应该将pictureBox1现在的image作为Graphics。
      

  2.   

    这样也不行,我想让鼠标在中间移动时产生的线条在PictureBox Refresh时都擦掉,所以必须用this.pictureBox1.CreateGraphics()。
    但由于pictureBox不够大,我在鼠标移动到pictureBox边框附近时又给pictureBox的size重新赋了值,这时pictureBox变大了,但pictureBox的Image却没跟着变大,
    所以在MouseUp事件里保存最终的线条时,用Graphics.FromImage(this.pictureBox1.Image)老是只能保存一部分。但this.pictureBox1.CreateGraphics()却是能画出全部的,可是却保存不了。
       该怎么办?
       所以我想有没有办法用this.pictureBox1.CreateGraphics()作Graphics,同时又能保存入pictureBox呢?
      

  3.   

       Graphics g = Graphics.FromImage(this.pictureBox1.Image);
              ...... 
        this.pictureBox1.Refresh();