当前位置:编程学习 > C#/ASP.NET >>

怎么从一个窗体向另一个窗体画曲线

从A窗体向B窗体画曲线,但B窗体最小化再最大化就被刷新了。怎么能在A窗体写代码,在B窗体的PAINT中画图,还是用其它的方法呀? --------------------编程问答-------------------- 定义一个public的类,里面定义一个public事件和事件的触发函数(public)
    public class toPaintForm2
    {
        public event Action<Graphics> event_p;

        public void onPaint2(Graphics g)
        {
            if (event_p != null)
            {
                this.event_p(g);
            }
        }
    }

Form1里面:
        private void button1_Click(object sender, EventArgs e)
        {
            toPaintForm2 paintClass = new toPaintForm2();
            Form2 f2 = new Form2(paintClass);
            paintClass.event_p += new Action<Graphics>(paintClass_event_p);
            f2.Show();
}
 void paintClass_event_p(Graphics obj)
        {
            obj.DrawString("Draw a string from From1", new Font("宋体", 20), new SolidBrush(Color.Green), 0, 0);
        }

Form2 里面:(Form2_Paint是Form2的Paint事件绑定的方法)

        public Form2(toPaintForm2 cls)
        {
            InitializeComponent();
            this.cls = cls;
        }

        private toPaintForm2 cls;

        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            cls.onPaint2(e.Graphics);
        }

--------------------编程问答-------------------- 我改成VB.NET试一,先谢谢了! --------------------编程问答-------------------- 把A窗体画的曲线实时保存为一个bitmap,并保证B能访问这个图片,在B每次重绘时将此bitmap绘制到B窗体上 --------------------编程问答-------------------- 我怎么照着抄报错呀,能直接给我个例子吗? --------------------编程问答-------------------- 题目太牛,两个窗体还能用线连起来 --------------------编程问答-------------------- 我觉得3楼的是正解!
LZ先在一个窗体上画线试下,然后,再解决两个窗体吧。。。
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,