在c#中创建子表单 [英] creation of child forms in c#

查看:90
本文介绍了在c#中创建子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以创建除了mdi表单之外的子表单...

在我的应用程序中我有一些小的弹出窗口表单和一些控件..如果弹出窗体打开并且用户尝试关闭应用程序或最小化应用程序弹出窗体也应该最小化...

mdi不适合我的应用程序,因为我的父屏幕中有太多的控件。

请帮助

is there any way to create childforms othere than mdi forms...
in my application i have some small pop up windows forms with some controls.. if pop form is open and user try to close the application or minimize the application pop form should also minimized...
mdi is not suitable for my application because i have too many controls in my parent screen.
please help

推荐答案

你可以做到,但你必须自己做:没有自动方式。

这并不困难:只保留一个打开表单的集合(并在创建它们时为每个表单处理FormClosed事件以从集合中删除它们)以及何时获得主要表单Resize您检查最小化/恢复的事件,并在您的集合中的每个表单上调用相应的方法。

You can do it, but you have to do it yourself: there is no "automatic" way of doing that.
It's not difficult: just keep a collection of the "open" forms (and handle the FormClosed event for each when you create them to remove them from the collection) and when you get the main forms Resize event you check for minimize / restore and call the appropriate method on each form in your collection.
private void MainForm_Resize (object sender , EventArgs e)
    {
    if (WindowState == FormWindowState.Minimized)
        {
        // Minimize the collection 
        }
    ...
    }


这篇关于在c#中创建子表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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