我要传得是一个实体类~!使用委托在窗体间传递哈。
麻烦各位大大帮忙下 谢谢了,如果不行的话 传个ID也行。

解决方案 »

  1.   

    灵活的办法,定义一个公共类,将其中的成员变量设置为static作为传值缓存:public class Common{
       public static Type val;
    }然后两个窗口类都 using 公共类所在命名空间即可。
      

  2.   

    这个很简单的!下面这个Form2就可以看做一个自定义的类,其他的一样。
    Form2:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace DelegateDemo
    {
        public partial class Form2 : Form
        {
            public delegate void dlgOnFormLoad(Form2 loadedForm);
            public event dlgOnFormLoad OnForm2Loaded;        public Form2()
            {
                InitializeComponent();
            }        private void Form2_Load(object sender, EventArgs e)
            {
                if (OnForm2Loaded != null)
                {
                    OnForm2Loaded(this);
                }
            }
        }
    }Form1:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace DelegateDemo
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm2 = new Form2();
                frm2.OnForm2Loaded += new Form2.dlgOnFormLoad(frm2_OnForm2Loaded);
                frm2.Show();
            }        void frm2_OnForm2Loaded(Form2 loadedForm)
            {
                MessageBox.Show(loadedForm.Text + "已经加载完毕");
            }
        }
    }