Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slowness in C#.net windows form resize when form has many dropdownlist controls

Tags:

c#

.net

winforms

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?

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?

like image 760
Uğur Gümüşhan Avatar asked Jan 06 '12 20:01

Uğur Gümüşhan


1 Answers

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:

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

Look here for concrete example:

Prevent window redraw when resizing c# windows forms

Should work for you.

like image 187
Tigran Avatar answered Nov 13 '22 13:11

Tigran