Accelerating Slow, Intensive CPU Scrolling in WinForms

How to speed up UserControls scrolling in a WinForms application?

My main form has problems with fast scrolling on slower machines - for every small increase in scroll speed, processor intensity is required.

My form has approximately fifty UserControls (with multiple fields) located one below the other. Ive tried to intercept OnScroll and UserPaint to eliminate some unnecessary re-paints for very small scroll events, but at the heart of Paint is still called.

How can I optimize scrolling on slower machines?

+4
source share
3 answers

The try-and-true method is designed to use an off-screen raster image, which is updated only when the actual data provided by your control; then all OnPaint needs to do is display a bitmap on the screen.

If your drawing process is intensive, and since you have so many controls, you will find that it greatly affects the performance of your application.

Please note that using the DoubleBuffering control property in your case will not help - it allows WinForms to display on the screen bitmap before displaying on the screen, but this still happens with each paint cycle, since WinForms does not track when the view has changed.

So, you have to collapse yourself. It is not that difficult. Here's what looks like a pretty good article on the subject .

+3
source

You can also increase the scroll step size. for instance

 panel1.VerticalScroll.SmallChange = 100; 

Allows the panel to scroll through the contents of 100 units vertically per click of the scroll bar button. So you take big steps every time, which can make you feel better, at least. And you can do the same for the horizontal scrollbar, of course.

+2
source

I used tabs to exclude scrolling.

+1
source

Source: https://habr.com/ru/post/1308676/


All Articles