zoukankan      html  css  js  c++  java
  • C# 限制窗体弹窗显示必须关闭后才能重新实例化窗体

    主窗体Form1

    弹窗窗体Form2

    在主窗体Form1的Button点击事件中加入:

    private void btnXXX_Click(object sender, EventArgs e)
    {
        if (Form2.Instance == null || Form2.Instance.IsDisposed)
        {
            Form2 frm = new Form2();
            Form2.Instance.Show();
        }
        else
        {
            Form2.Instance.Activate();
        }
    }

    在弹窗窗体Form2中加入:

    private static Form2 _instance = null;
    public static Form2 Instance { get { return _instance; } }
            
    public Form2()
    {
        InitializeComponent();
        _instance = this;
    }
    
    private void Form2_FormClosed(object sender, FormClosedEventArgs e)
    {
        _instance = null;
        this.Dispose();
    }
  • 相关阅读:
    sort排序
    js数组
    json数据格式 与 for in
    js 定时器
    鼠标滚轮事件
    cookie
    POJ 2387 Til the Cows Come Home
    POJ 1459 Power Network
    HDU 5389 Zero Escape
    HDU 5387 Clock
  • 原文地址:https://www.cnblogs.com/zhengzc/p/11168881.html
Copyright © 2011-2022 走看看