绘图是根据不同条件多次画上去的。一旦窗体切换,图形就不在了。怎么解决呀,多多指教!
新来,分不多,还请包涵。

解决方案 »

  1.   

    好象不行吧.只能在paint事件里,你可以在外面设置条件,在paint事件里根据条件来显示不同的界面.不管调用无效还是刷新,都会引发paint事件,如果你用其他事件的话,不能保证能画啊
      

  2.   

    依据你的不同条件
    写出不同的方法,针对你想要的效果然后在 paint 方法里根据你的条件选择方法进行调用
    if(..)
        方法1
    else if(..)
        方法2
    ...
    ...
    都放在里面只能这样了
      

  3.   


    public class ShapeBase
    {
      Pen m_pen;
      Color m_color;
      float m_thinness;
      int m_z_index;
      public ShapeBase(){.........}
      public virtual void Draw(Control c){.........}
    ............
    .........
    }
    public class Point:ShapeBase
    {
      PointF m_onlyPoint;
      public Point():base(.......){}
      public override void Draw(Control c)
      {
       //.....................
      }
    }
    public class Line:ShapeBase
    {
      PointF m_startPoint;
      PointF m_stopPoint;
      public Line():base(......){}
      public override void Draw(Control c){................}
    }public class Form1:Form
    {
      //.........................
      //吧你的图形保存到这个List里。
      List<ShapeBase> m_Shapes = new List<ShapeBase>();
      public void DrawGraphics()
      {
         foreach(ShapeBase shape in m_Shapes)
             shape.Draw(this);
      }
    }
    在你的Program.cs里。
    static class Program
    {
      static void Main()
      {
        Form1 frm = new Form1();
        frm.Show();
        while(frm.Created)
        {
          frm.DrawGraphics();
          Application.DoEvents();
        }
      }
    }
      

  4.   

    谢谢各位了。我还是在paint之外改变数据,刷新让paint去画。暂时这样吧。分不多请原谅。