Compact Framework - get all open forms

旧城冷巷雨未停 提交于 2019-12-06 14:32:15

问题


I am making a Windows CE application in which the user can change the GUI language at runtime. I have implemented my own translation logic in the Load event of the form.

Now, I would like to update all open forms when the user changes the language. Is there a way (in Compact Framework!!) to retrieve all open forms of the application?


回答1:


You can create a FormManager class that you use to instantiate all of your forms. This would give the manager the opportunity to track the lifespan of those forms by listening for their Close event, and to call methods on them en masse if they utilize a common interface (say one with a OnUiLanguageChanged method).

Alternatively, you can create an object in your application that exposes an event that each Form can subscribe to. In that way, you don't need to know which forms are open. Intsead all open forms are listening for a UiLanguageChanged event as long as they aer open, and if they recieve it they can update themselves appropriately.



来源:https://stackoverflow.com/questions/10278606/compact-framework-get-all-open-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!