假设主窗体A中有一个整数n,怎么把它专递给另一个窗体B,(B没有继承自A)!各位仁兄指点指点!

解决方案 »

  1.   

    例如: 
    public form2(int count) 

      this.count=count; 

    上面是form2的构造函数 
    调用时 
    private void button_click(object sender, EventArgs e) 

    form2 frm=new form2(count); 
    }结贴吧
      

  2.   

    http://www.5ixue.com/e/tool/gfen?id=289153
      

  3.   

    这是form1调用form2的情况,如果是form2回传给form1的话就得用委托和事件
    ,或窗体属性了
      

  4.   

    方法一: 
    form1中的代码 namespace CurrentChange
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            Form2 f;
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if (f == null)
                {
                    f = new Form2();
                    f.GetChangeValue(textBox1.Text);
                    f.Show();
                }
                else
                {
                    f.GetChangeValue(textBox1.Text);
                }
            }
        }
    }form2中的代码: namespace CurrentChange
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }        private void Form2_Load(object sender, EventArgs e)
            {
                
            }        public void GetChangeValue(string content)
            {
                this.textBox1.Text = content;
            }
        }
    }
      

  5.   

    新建一个data类,把数据放到这个类里面,form1和form2访问data类。
      

  6.   

    方法太多了。不过最好使用消息循环机制。WINDOWS里面全部是这么干的。
      

  7.   

    给b窗体定义一个属性private int _n;
    public int n
    {
      get ...
      set ...
    }//然后调用的时候
    FormB b = new FormB();
    b.n = this.n;
    b.Show();