如何关闭菜单项上所有打开的窗体,在窗口应用程序中单击. [英] how to close all opened form on menu item click in window application.

查看:86
本文介绍了如何关闭菜单项上所有打开的窗体,在窗口应用程序中单击.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在asp.net中的窗口应用程序中工作.在其中我使用了MenuScript,并且每次菜单上的单击表单每次都打开.
问题:每次单击菜单项都会生成新的页面实例.

要求:我希望当我单击菜单打开菜单时,该表单应该打开,而所有其他打开的表单都应该关闭.

请给我任何想法,文章或链接来解决我的问题.

Hello All,

I am working in a window application in asp.net. in which i used MenuScript and on every menu click form is open every Time.
Problem : On every click of menu items new instance of page is generated.

Requirement : I want that when i open a form on click to a menu that form should open and all other opened forms should be closed.

please give me any idea, article or link to solve my problem.

推荐答案

让您的菜单表单的名称为Menu.因此,在打开新窗口之前,请运行以下代码段.

Let your menu form''s name is Menu. So run the snippet below before your new window opens.

List<Form> openForms = new List<Form>();

foreach (Form f in Application.OpenForms)
    openForms.Add(f);

foreach (Form f in openForms)
{
    if (f.Name != "Menu")
        f.Close();
}


这篇关于如何关闭菜单项上所有打开的窗体,在窗口应用程序中单击.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆