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

编程入门 行业动态 更新时间:2024-10-23 11:22:16
本文介绍了加载具有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窗体

本文发布于:2023-11-09 15:45:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572766.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   窗体   控件   加载   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!