假设在Form1中打开Form2,1.在Form2类中定义一个Form1类型的变量
public Form1 f1;2.将Form1的button1的Modifiers设置为public , 在Form1中这样打开Form2
Form2 f2 = new Form2();
f2.f1 = this;
this.button1.Enabled = false;
f2.Show();3.在Form2的Close事件中,
f1.button1.Enabled = true;

解决方案 »

  1.   

    好像楼上的方法不行吧?步骤3.私有变量能实现吗?我觉得应该这样:
    在Form1类中定义一个public类型的代理
    public delegate delfun;
    then define a fuction like this:
    private void fun()
    {
       this.button1.enabled=true;
    }
    when you open another Form2,you must transform the delegate function to Form2:
      Form2 f2 = new Form2(new delfun(this.fun));
      this.button1.enabled=false;
      f2.showdialog();
    then you should receive the delegate function like this:
      private delegate fun;
      public Form2(delegate delegatefun)
      {
        this.fun=delegatefun;
      }
    of course ,before your closing the latter form ,you should:
       this.fun();