如何加快Windows窗体中加载控件的过程。 [英] How to speed up the process of loading controls in windows form.
问题描述
大家好,
任何人都可以告诉我如何加快将控件加载到窗体中的过程,我有一个窗体,我在其中添加了一个flowlayoutpanel&进入它的几个按钮。这根据用户所需的按钮而不断变化。基本上它有25排& 4列或有时12行& 4列。用户可以选择这些选项中的任何一个,一旦用户选择或点击特定选项,所有先前存在的形成被清除&选择1形成。在此期间,观察到巨大的延迟。如何提高这种操作的速度....?我已将doublebuffered设置为true但仍然没有用。
我也试过这段代码,
受保护 覆盖 CreateParams CreateParams
{
get
{
var parms = 碱跨度> .CreateParams;
parms.Style& = ~0x08000000;
return parms;
}
}
一切都是徒劳的。所以任何帮助将不胜感激。
提前谢谢。
我可以建议两个选项:
1.使用SuspendLayout
和ResumeLayout
方法
< pre lang =cs> flowPanel.SuspendLayout();
flowPanel.Controls.Clear();
// 在此处向flowPanel添加控件
flowPanel.ResumeLayout();
2.删除当前的flowPanel并创建一个具有相同属性的新窗口
// this =当前表单
此跨度> .SuspendLayout();
this .Controls.Remove(flowPanel);
var fp = new FlowLayoutPanel();
fp.Location = new 点( 100 , 10 跨度>);
fp.Size = new 大小( 200 , 200 跨度>);
// 设置其他fp属性
// 在此处向fp添加控件
this 跨度> .Controls.Add(FP);
this .ResumeLayout();
Hi all,
Can anybody tell me how to speed up the process of loading controls into windows form, i have a windows form in which i have added a flowlayoutpanel & few buttons into it. This keeps varying based on the buttons required by the user. Basically it has 25 rows & 4 columns or sometimes 12 row & 4 columns. The user can choose any of these options, once the user selects or clicks on the particular option, all the previously present formation is cleared & chosen 1 is formed. During this time a huge delay is observed. How to increase the speed of such operation....? I have set doublebuffered to true but still no use.
Also i tried with this piece of code,
protected override CreateParams CreateParams
{
get
{
var parms = base.CreateParams;
parms.Style &= ~0x08000000;
return parms;
}
}
All in vain. So any help will be appreciated.
Thanks in advance.
i can suggest two options:
1. useSuspendLayout
andResumeLayout
methods
flowPanel.SuspendLayout(); flowPanel.Controls.Clear(); // add controls to flowPanel here flowPanel.ResumeLayout();
2. remove current flowPanel and create a new one with the same properties
// this = current form this.SuspendLayout(); this.Controls.Remove(flowPanel); var fp = new FlowLayoutPanel(); fp.Location = new Point(100,10); fp.Size = new Size(200,200); // set other fp properties // add controls to fp here this.Controls.Add(fp); this.ResumeLayout();
这篇关于如何加快Windows窗体中加载控件的过程。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!