关键词搜索

源码搜索 ×
×

c# 如何判断当前窗体是否打开

发布2020-10-30浏览2856次

详情内容

  1. using System.Text;
  2. using System.Threading.Tasks;
  3. using System.Windows.Forms;
  4. namespace WindowsFormsApplication3
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public static string username;
  9. public Form2 form2 = null; //定义窗体
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14. private void Form1_Load(object sender, EventArgs e)
  15. {
  16. }
  17. private void button3_Click(object sender, EventArgs e)
  18. {
  19. username = "123456";
  20. MessageBox.Show(username);
  21. if (form2 == null) //判断窗体是否存在
  22. {
  23. form2 = new Form2();
  24. form2.Show();
  25. this.Hide();
  26. }
  27. }
  28. }
  29. }

 

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载