I have a control which the user can resize with the mouse. When they move the right side, I just change the width, and everything works fine.
However, when they move the left size, I have to change the Left and Width properties. The right hand side of the control visibly twitches, showing the old width in the new position.
It still twitches if I set both left and width at once using Bounds; whether or not I use SetStyle with any of UserPaint, Opaque, OptimizedDoubleBuffer, AllPaintingInWmPaint or ResizeRedraw; and whether or not it's double buffered. It still twitches if I call SuspendLayout()/ResumeLayout() on either the control or its parent.
How do I stop controls from twitching when I change their left positions and their widths?
You might want to try calling Control.SuspendLayout() on the containing form before moving / resizing, then Control.ResumeLayout().
It sounds like no matter what mode you set the control to, some event that fires when you change the bounds is redrawing it before both values are set. It may have something to do with the form.
EDIT: I saw this similar question on SO, you mentioned you had already used SetStyle(), but maybe there is some combination of options you can choose that will give you the desired effect.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With