关闭后如何启用按钮? C#.NET [英] How do I enable a button after a for closes? C# .NET

查看:79
本文介绍了关闭后如何启用按钮? C#.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void btnSignUpOpt_Click(object sender, EventArgs e)
{
    Members aMember = new Members();
    aMember.Show();
    (sender as Button).Enabled = false;
            
}





这是我如何禁用它,但我无法找到一种方法在我之后启用它关闭表格aMember。



我尝试过:



我试过:



this is how i disable it, but i cant find a way of enabling it after i close the form aMember.

What I have tried:

I tried:

btnSignUp.Enable = true;



但这会使即使表格已经打开也会启用按钮


but that would make the button be enabled even if the form is already open

推荐答案

有很多不同的方法可以做你想做的事:

1.打开从模式开始,然后按钮事件中的代码将暂停,直到您关闭aMember表单;

2.从aMember关闭事件启用btnSignUpOpt

3.传递一个Action在显示之前到aMember表单,然后在关闭之前调用aMember中的操作,其中Action启用按钮

4.在显示aMember表单之前在主机表单中收听结束事件并在启用btnSignUpOpt时启用btnSignUpOpt事件被捕获

5. an d等......
There are many different ways of doing what you want:
1. open the form modally, then the code in the button event will pause until you close the aMember form;
2. enable the btnSignUpOpt from the aMember close event
3. pass an Action to the aMember form before showing, then call the action from aMember before closing where the Action enables the button
4. listen to the closing event in the host form before showing the aMember form and enable the btnSignUpOpt when the event is captured
5. and so on...


这篇关于关闭后如何启用按钮? C#.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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