本文介绍了父母子女形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
向大家问好 我以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; }
更多推荐
父母子女形式
发布评论