如何实现 通过 点击form2中的按钮  改变form1中空间的属性 比如我要用一个form2中的button 设置form1中的timer 控件的开或者关我是这么办的  就是 把form1中的timer1 设置为public    然后在form2中 写下面的代码
button1—click()

form1 fr1=new form1();fr1.timer1.enable=true;
}但是不行 没用反映 有高手能来指点一下么

解决方案 »

  1.   


       public event EventHandler StopTime;        public Form2()
            {
                InitializeComponent();
              
            }
           
            private void button1_Click(object sender, EventArgs e)
            {
                if (StopTime != null)
                {
                    StopTime(sender, e);
                }
            }///from1
       private void button1_Click(object sender, EventArgs e)
            {
                Form2 frm = new Form2();
                frm.StopTime += new EventHandler(frm_StopTime);            frm.ShowDialog();
            }        void frm_StopTime(object sender, EventArgs e)
            {
                this.timer1.Enabled = false;
            }
      

  2.   

    你是想改变原有form的enable还是新出来的enable啊,你已经new出一个新的了。fr1=new form1(); 
      

  3.   

    两个窗体肯定是通过一定关系关联起来的,要么1是主窗体,要么2是,要么都是MDI子窗体,你只需要在设置1的timer的时候,设置那个实例化的对象窗体就可以了。
      

  4.   

    直接操作public的是可以实现的,没必要用事件吧
      

  5.   

    没太明白楼主的意思;你的form1是已经存在了的吗?如果已经存在你干嘛还用new来创建新的form1?还有,你说没有用,你的判断依据是什么?不行的话试试timer.start()方法,效果同timer.enable = true
      

  6.   

    那你将原来的窗体中的timer启动即可
      

  7.   


    button1—click() 
    { 
    oldform1.timer1.enable = true;}
      

  8.   


    比如我原来的窗体叫mainform 直接在新窗体form2中 写 mainform。timer。enable=true;
      

  9.   

    这么写好像写不到吧 mianform. 好像引不了 timer
      

  10.   

    this.timer1.Enabled = false;