0

I have created a dynamic GUI library based on Windows Forms (C#) and I am using it in complex Forms with many Controls being modified at the same time.

I have had performance issues during size and position changes and that's why I measured the time needed for each change. These are examples of my measurements (where I actually have a problem):

  • TextBox Width set (2,0001 msecs, 3929 ticks)
  • TextBox Left set (1 msecs, 2417 ticks)
  • ComboBox Width set (3,0001 msecs, 6906 ticks)
  • ComboBox Left set (1 msecs, 1318 ticks)

First of all: I know it is not much for a TextBox or ComboBox to take 2-3 msecs to change it's Width, but it would help me greatly if I could bring this time down to as less as it gets. I have 100-300 Controls in each form, so I get a lag of 400 msec - 1200 msec each time I resize the whole thing, which creates a bad result.

Secondly: The resizing of my forms would be smoother, if I had a way to avoid flickering, while the Widths and Lefts are being changed. If I use Hide and Show in the whole form, I have the form disappearing for a moment and showing up again. If I don't, the Controls flicker. Is there a way to avoid flickering?

EDIT: Espesially for comboboxes I get realy slow times, also depending on the number of items they have. But why should the number of items delay a width set. I am sharing some additional results for combobox times:

  • ComboBox Width set (1 msecs, 3056 ticks)
  • ComboBox Width set (1,0001 msecs, 2548 ticks)
  • ComboBox Width set (0 msecs, 1241 ticks)
  • ComboBox Width set (1,0001 msecs, 1646 ticks)
  • ComboBox Width set (1 msecs, 1052 ticks)
  • ComboBox Width set (1,0001 msecs, 3626 ticks)
Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101
  • 2
    I measure times x8 times faster than that. You are probably triggering layout events that make it expensive, the kind that don't run when you use SuspendLayout(). Which you can call in OnResizeBegin(), ResumeLayout in OnResizeEnd(). Don't expect miracles from a window with *that* many controls, it is a piggy. – Hans Passant Nov 15 '14 at 15:45
  • You are right Hans Passant. My measurements weren't exactly clean. I get what you say for the Textboxes. But the Comboboxes are as slow and even slower in some cases. I am posting some more results. – Stefanos Kargas Nov 15 '14 at 19:42
  • 1
    Regarding the flicker problem, have you tried turning on double buffering? http://msdn.microsoft.com/en-us/library/3t7htc9c%28v=vs.110%29.aspx and http://stackoverflow.com/questions/3718380/winforms-double-buffering – RenniePet Nov 15 '14 at 22:39
  • Thank you, it helped. Especially the override of CreateParams – Stefanos Kargas Nov 24 '14 at 12:31

0 Answers0