zoukankan      html  css  js  c++  java
  • 【转】只打开一个子窗口

    检查要打开的窗口是否已经是打开状态

    private void TestApplicationOpenFormsMethod()
    {
    #region 测试代码一
    Form temp_form = new Form();
    temp_form.Name = "MyForm";

    foreach (Form f in Application.OpenForms)
    {
    if (f.Name == temp_form.Name)
    {
    MessageBox.Show("I Found it.");
    return;
    }
    }
    MessageBox.Show("I not found it.");//代码二可以执行到这里,说明Application.OpenForms集合是没有这个temp_form的。
    return;
    #endregion

    #region 测试代码二
    Form temp_form = new Form();
    temp_form.Name = "MyForm";
    temp_form.Show();//主要就是这里与测试代码一的不一样。

    foreach (Form f in Application.OpenForms)
    {
    if (f.Name == temp_form.Name)
    {
    MessageBox.Show("I Found it.");//代码二可以执行到这里,说明Application.OpenForms集合是有这个temp_form的。
    return;
    }
    }
    MessageBox.Show("I not found it.");
    return;
    #endregion

    //现在主要我想解决的是。
    //我想窗体不想Show()之后Application.OpenForms里有我想要的指定的已经New过的Form;
    //是否有相关的Application.属性呢?
    //我也不可能用Form.Show()之后,再马上用Form.Hide()吧?这方法帮笨了。
    //如果有现成的方法可以在不用Form.Show()后,又可以拿到所有已经new()过的(即在内存的位置的)的窗体的集合。
    //我该怎么写呢?
    }



  • 相关阅读:
    css3实现文本渐变
    元组--购物车实战
    js事件冒泡
    openssl生成v3版自签证书
    linux中可以在哪些地方增加环境变量
    linux下如何找到USB转串口
    linux下通过shell命令测试串口
    CANopen协议
    ubuntu使用虚拟can(vcan)
    移植python3到flash有限的arm
  • 原文地址:https://www.cnblogs.com/chusiping/p/2251552.html
Copyright © 2011-2022 走看看