I have created a form in C# (VS2010) which contain (among other) a textbox control. The textbox may contain large amount of data at some point (~3 million chars).
When scrolling or moving the form around no problems are encountered, but when the form is minimized and restored back again, a repaint sequence (I believe) is triggered which causes a big lag of around 5-10 seconds for the form to be repainted.
I've already tried several solutions:
Using double buffer – according to what I've read, double buffering applies only to the form itself and not to its controls
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);
Disabling the textbox redrew once minimized using: SendMessage(this.my_textBox.Handle, WM_SETREDRAW, false, 0);
and enabling back after form is restored. I've noticed that the form repaint lag exist also if I don't re-enable the textbox repaint.
Manual double buffer using a bitmap – similar results as #1.
I read somewhere that this issue might be related to the textbox control trying to shrink or adjust to the amount of data, but couldn't override it.
I previously had the same project in MFC, but didn't encounter any repaint or lagging issues there.
Please advise me how to solve this issue.
Found the problem!!! Issue was related to the textbox Anchor property. once i removed it, window restore was immediate. BTW, the new custom class isn't required
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