标签:tty open cas ati def col else pre eof
/// <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(); }
标签:tty open cas ati def col else pre eof
原文地址:https://www.cnblogs.com/lee24789229/p/10364113.html