我创建了一个ParentForm。从ParentForm的菜单中,我从ChildForm菜单项创建了一个ChildForm。创建ChildForm时,我在ParentForm上禁用了Childform菜单项。 我需要设置和引用以在ParentForm上创建ChildForm菜单项 关闭ChildForm时启用。
谢谢
的Tamas
答案 0 :(得分: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
}
}
答案 1 :(得分: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);"