加载具有200多个控件的Windows窗体 [英] Loading Windows form with over 200 controls

查看:74
本文介绍了加载具有200多个控件的Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单有200多个控件! 加载表单并绑定控件大约需要7秒钟.

My form has over 200 control(s)! It takes about 7 seconds to load the form and bind the controls.

我已经使用一些性能分析器跟踪了该应用程序,但是除了构造函数的形式外,我没有找到任何带有HOT标志的东西.

I've traced the application with some performance profilers , but I didn't find anything with HOT flag except the constructor's of form.

我想知道是否可以像backgroundWorker(multithreading)一样调用 InitializeComponent 方法!

I would like to know that is it possible to call InitializeComponent method with sth like backgroundWorker (multithreading) !?

推荐答案

否,线程化对您没有帮助.需要在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.

这篇关于加载具有200多个控件的Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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