在Mdi窗体中,使一个窗体的实例只显示一次,调用时,如果已经存在,则显示原来存在的窗体,如果不存在,直接显示新窗体:

            Show1 s1 = new Show1();
            s1.Tag = "s1";
            bool isExists = false;
            foreach(Form f1 in this.MdiChildren)
            {
                if (f1.Tag.ToString() == "s1")
                {
                    isExists = true;
                    f1.Activate();
                    break;
                }
            }
            if (!isExists)
            {
                s1.MdiParent = this;
                s1.Text = ((ButtonItem)sender).Text;
                s1.Show();
            }

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2022-01-03
  • 2021-09-18
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2021-09-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-05-31
  • 2021-09-22
相关资源
相似解决方案