zoukankan      html  css  js  c++  java
  • C# 查找打开的窗口

    同属于一个应用程序的好多窗口,要想限定一个窗口只打开一次,如果打开的话就激活,使用下面的代码
     1     private void button1_Click(object sender, EventArgs e)
     2        {
     3            bool isfind = false;
     4            foreach (Form fm in Application.OpenForms)
     5            {
     6                if (fm.Name == "Form2"{ fm.Activate(); fm.WindowState = FormWindowState.Normal; return; }
     7            }

     8            if (!isfind) { Form fm = new Form2(); fm.Show();  }
     9           
    10        }

    如果是在MDI父窗口中打开好多子窗口,查找子窗口的代码:
                  foreach (Form chform in this.MdiChildren)
                    
    {
                        
    if (chform.Text == "子窗口的标题")
                        
    {
                            chform.Activate();
                            Isfind 
    = true;

                        }


                    }
  • 相关阅读:
    一步一步CCNA之二:路由器特权模式
    uncompress bz2
    Protothreads Lightweight, Stackless Threads in C
    sohu的正版美剧都挺不错的
    Ebot crawler
    大数据时代的创新者们
    technology company
    slogan
    娱乐新闻都怎么搞的,真不给力啊
    售楼小姐比较漂亮
  • 原文地址:https://www.cnblogs.com/tiasys/p/1155037.html
Copyright © 2011-2022 走看看