缓慢的C#.NET Windows窗体调整大小时,表格有许多DropDownList控件有许多、窗体、控件、缓慢

2023-09-03 03:01:55 作者:未曾深吻

我做了一个窗户,它被放置在一个网格(而不是一个DataGrid)和内部的许多下拉列表的形式,当我用锚=左右顶部底部和码头=填充选项在所有这些,形式调整大小沾在运行时速度慢。

I made a windows form with many dropdown list which are placed inside a grid(not a datagrid) and when I use anchor=left right top bottom and dock=fill options in all of them, the form resize gets slow on runtime.

做什么用的码头和锚的选择问题?

What's the problem with dock and anchor options?

是它形成了一个普遍的问题?它是使用.NET组件和Windows窗体的一般缺点?

Is it a general problem with forms? Is it a general disadvantage of using .net components and windows forms?

我没有对控制调整大小处理的任何自定义事件,所以这个问题是关于微软开发的控制。我应避免使用船坞=填?

I don't have any custom events handled on control resize, so the problem is about the controls Microsoft developed. Should I avoid using dock=fill?

推荐答案

这是一个正常的,它消耗的处理器在每个调整移动表格的形式调整表格布局面板这力量调整和复位子控件(下拉列表),因为有锚属性。

It's a normal that it consumes your processor as on every resize move form forms resize table layout panel which forces resize and reposition child controls (dropdowns), as there is anchor property setuped.

还有一个绝招,以避免调整时创建一个无奈的用户:

There is a trick to avoid to create a frustration for user when resizing:

使用 SuspendLayout() ResumeLayout() BeginResize() EndResize()事件处理程序。

Use SuspendLayout() and ResumeLayout() on BeginResize() and EndResize() event handlers.

在这里寻找具体的例子:

Look here for concrete example:

$p$pvent调整的C#Windows窗体时窗口重绘

应该为你工作。