日期:2014-05-18 浏览次数:20997 次
public partial class ShowImagesForm : Form { private static ShowImagesForm sForm; private ShowImagesForm() { InitializeComponent(); } public static ShowImagesForm GetForm() { if (sForm==null) { sForm = new ShowImagesForm(); } return sForm; } private void ShowImagesForm_FormClosed(object sender, FormClosedEventArgs e) { sForm = null; }
------解决方案--------------------
private void ShowChildFrom(Form chfr, string fromname) { bool isfind = false; foreach (Form fm in Application.OpenForms) { if (fm.Name == fromname) { fm.Activate(); fm.WindowState = FormWindowState.Normal; return; } } if (!isfind) { Form fm = chfr; fm.Show(); } } private void ShowChildFrom(Form chfr, string fromname) { bool isfind = false; foreach (Form childrenForm in this.MdiChildren) { if (childrenForm.Name == fromname) { childrenForm.Visible = true; childrenForm.Activate(); return; } } if (!isfind) { Form fm = chfr; fm.Show(); } }