且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加载具有200多个控件的Windows窗体

更新时间:2023-12-06 08:43:34

否,线程化对您没有帮助.需要在UI线程上创建控件,以使应用程序完全正常工作.

No, threading will not help you. The controls need to get created on the UI thread for the application to work at all.

唯一合理的方法是查看创建表单时是否真的需要创建 all 200个控件,或者是否可以按需加载它们.

The only reasonable way would be to look into whether you really need to create all 200 controls when the form is created, or if you can perhaps have them load "on demand".

在不了解您的应用程序的情况下,不可能给出更具体的指导,但是也许您遇到的情况是并非同时使用所有控件,而是存在某种分页.如果是这种情况,则可以将每个页面"设置为一个用户控件,以便您可以根据需要加载和卸载页面.

Without knowing your application it's impossible to give more concrete guidance, but perhaps you have a situation where not all controls are in use at the same time, but rather that there is some sort of paging. If that is the case, each "page" could perhaps be made into a user control, so that you can load and unload pages as they are needed.