父母子女形式 [英] parent and child form

查看:85
本文介绍了父母子女形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向大家问好
我以form1作为父母,而我的孩子则是form2
在form1的按钮单击事件上,显示了form2的一个实例,并且该按钮被拒绝以不显示另一个实例,我想在form2的示例关闭时再次启用该按钮,我的用户可以单击它.
在form2的关闭表单上,我编写此代码

hello to all
i have form1 as parent and my child form is form2
on a button click event of form1 , an instance of form2 shows and the button is disabeld to dont show another instance , i want to when sample of form2 is closing the button is enabeled again and my user can click it on.
on the form closing of form2 i write this code

private form2_closing(object sender , formclosingeventargs e)
{
form1.buttonname.enabeld=true;

}


但这不起作用
请帮帮我.
谢谢.


but it does not work
please help me.
Thanks.

推荐答案

更改它:将处理程序移到form1中:
Form1按钮单击事件:
Change it: move the handler into form1:
Form1 button click event:
Form2 f = new Form2();
f.FormClosing += new FormClosingEventHandler(Form2_FormClosing);
myButton.Enabled = false;
f.Show();


然后将处理程序添加到Form1:


Then add the handler to Form1:

void Form2_FormClosing(object sender, FormClosingEventArgs e)
    {
    myButton.Enabled = true;
    }


这篇关于父母子女形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆