zoukankan      html  css  js  c++  java
  • 判断窗体是否已存在实例

    /// <summary>判断窗体是否已存在实例
            /// 
            /// </summary>
            /// <param name="type">窗体类型</param>
            /// <returns></returns>
            public static Form ExistedForm(Type type)
            {
                return Application.OpenForms.Cast<Form>().FirstOrDefault(form => form.GetType() == type);
            }

    使用方法:

                Form isExist = ExistedForm(typeof(Form1));
                if (isExist == null)
                {
                    Form1 Frm = new Form1();
                    Frm.Show();
                }
                else
                {
                    isExist.WindowState = FormWindowState.Normal;
                    isExist.Activate();
                }

     窗体仅显示一个

                FrmInfo frmInfo = GenericSingleton<FrmInfo>.CreateInstrance();
           frmInfo.Show(this);
  • 相关阅读:
    活动安排问题
    完美字符串
    Codeforces Round #696 (Div. 2) 解题报告
    Codeforces 1459D
    Codeforces 25D
    POJ 1847
    LightOJ 1074
    POJ 3159
    POJ 1511
    POJ 1502
  • 原文地址:https://www.cnblogs.com/leebokeyuan/p/10364113.html
Copyright © 2011-2022 走看看