-1

我创建了一个 ParentForm。从 ParentForm 的菜单中,我从 ChildForm 菜单项创建了一个 ChildForm。创建 ChildForm 时,我将 ParentForm 上的 Childform 菜单项设置为禁用。在关闭 ChildForm 时,我必须设置和引用什么才能使 ParentForm 上的 ChildForm 菜单项启用。

谢谢

塔马斯

4

2 回答 2

0
    ParentForm form;
    public ChildForm(ParentForm _form) //pass ParentForm as Parameter
    {
        InitializeComponent();
        form = _form; //save Parameter to variable form
    }
    //raised when Form was closed
    private void ChildForm_FormClosed(object sender, FormClosedEventArgs e)
    {
        //set item to public modifier in properties window or specify getter and setter, then you can set it set it to enabled again like this
        //Pseudo: form.menu.item.enabled = true;
    }
    //create Instance of ChildForm like this "ChildForm child = new ChildForm(this);"
于 2013-10-21T21:47:16.830 回答
0
public partial class myParent : Form {
      ...
      ...
      public myParent {
             initChildren();
      }
      void initiChildren() {
          myChildAlpha = new ChildForm();
          myChildAlpha.FormClosed += new FormClosedEventHandler(enable_menu)    
      }
      void enable_menu(object sender,FormClosedEventArgs e) {
          //check if sender == ChildForm -> if so enable the proper menu
      } 
}
于 2013-04-14T09:37:17.487 回答