我编了个MDI窗体,运行主窗体菜单时,我menuItem1.Enabled=false了,
现在我想在子窗体关闭时再true回来!我在子窗体的关闭事件里写Form1.menuItem1.Enabled=true却编译不通过!怎么办啊?
 我把Form1的menuItem1给Public了,也不行!
拜托

解决方案 »

  1.   

    ref:
    http://blog.csdn.net/Knight94/archive/2006/08/22/1104957.aspx使用其中提到的delegate方法
      

  2.   

    Form1在你的子窗口中可能并不认识。
    建议1:使用委托,Knight94(愚翁)的提议
    建议2:在子窗口中存储对应MenuItem的对象,在FormClosing事件中重置MenuItem的Enable//在主窗口
    ChildForm frm=new ChildForm(menuItem1);
    ...//子窗口
    MenuItem menuItem; //定义public ChildForm(MenuItem menuItem)
    {
    this.menuItem = menuItem;
    this.menuItem.Enabled = false;
    ...
    }private void ChildForm_FormClosing(object sender, FormClosingEventArgs e)
    {
    if (this.menuItem!= null)
    {
    this.menuItem.Enabled= true;
    }
    }
      

  3.   

    是不是只想保留一个子窗体呢,如果是子窗体唯一性的问题,没必要绕这个弯路的,看愚翁的:
    http://blog.csdn.net/knight94/archive/2006/05/17/742324.aspx