RT

解决方案 »

  1.   

    可以定义属性
    public 控件类型 aaa
    {
       set{控件名=value;}
       get{return 控件名;}
    }
      

  2.   

    窗体或控件不也是对象吗?跟一般的参数传递有什么区别?void Method(Control con)
    {}
    调用:
    Method(button1);Method(this);....
      

  3.   

    可以用重载构造传public partial class Form2 : Form
        {
            private Form1 _Form1 = null;//在Form2中添加Form1这个属性 把Form1当成Form2的属性用 控件也成
            public Form2(Form1 _Form1)//重载构造 把Form1 或者 控件传过来
            {
                this._Form1 = _Form1;
                InitializeComponent();
                this.Show();  
            }
            
            public Form2()
            {
                InitializeComponent();
                this.Show();
            }
             
            这种传值也可以
            //public Form1 F1
            //{
            //    set { this._Form1 = value; }
            //}
            private void button1_Click(object sender, EventArgs e)
            {
                //用下面的格式就可以在Form2中使用Form1中的值 控件
                this._Form1.Visible = true;
                //this._Form1.Show();
                
            }
        }
      

  4.   

    以下一段代码 希望对你有帮助Form1
    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm2 = new Form2(this);
                frm2.Show();
            }
            //注意以下方法定义为共有的
            public string MyText 
            {
                get { return this.label1.Text; }
                set { this.label1.Text = value; }
            }        public void binding()
            {
                //绑定数据源
            }    }
    Form2
    public partial class Form2 : Form
        {
            //有一个参数的构造方法
            //或者 private Form frm=new Form();
            //使用frm是 强制转换" (From1)frm "
            private Form frm=new Form();
            
            public Form2(Form frm)
            {
                InitializeComponent();
                this.frm = frm;
            }
            private void button1_Click(object sender, EventArgs e)
            {
                this.frm.MyText = "AAAAAA";
                this.frm.binding();//使Form1重新绑定数据源
            }    }