问题
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