如何保持开放表格的集合 [英] How Do I Keep Collection Of Open Forms

查看:87
本文介绍了如何保持开放表格的集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
i希望在我的应用程序中保留我的打开表单集合

 Application.OpenForms 

但是当我改变时应用程序的文化,应用程序将重置并且在openForms中没有集合(count = 0)!

我该怎么做才能解决这个问题?

thx for your answer :)

解决方案

一种方法是创建一个派生自Form的MyForm类,并包含一个反映开放表单的静态集合。在Shown事件中,类将其添加到集合中,在Closed事件中将其删除。



为什么OpenForms集合应该为空我不确定 - 但是当文化发生变化时,它可能与所有者进行更改:OpenForms要求您的应用程序成为所有者以返回有效列表: https://msdn.microsoft.com/en-us/library/system.windows.forms.application.openforms(v = vs.110).aspx [ ^ ]

我没有查看改变文化的源代码,所以这只是猜测。

hi i want to keep my collection of open forms in my app with

Application.OpenForms

but when i change culture of app , Application will reset and has no collections in openForms (count =0 )!
what should i do to solve this issue?
thx for your answer:)

解决方案

One way is to create a MyForm class that derives from Form and contains a static collection which reflects the open forms. In the Shown event, the class adds it to the collection, in the Closed event it removes it.

Quite why the OpenForms collection should be empty I'm not sure - but it may have to do with the Owner changing when the culture is changed: OpenForms requires your app to be the Owner to return a valid list: https://msdn.microsoft.com/en-us/library/system.windows.forms.application.openforms(v=vs.110).aspx[^]
I haven't looked at the source code for changing culture though, so it's just a guess.


这篇关于如何保持开放表格的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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