Improving Paint performance while Scrolling

  • Thread starter Thread starter R3al1ty
  • Start date Start date
R

R3al1ty

I have a pretty large UserControl (2000 pixels high) on which around
1000 smaller controls are embedded. When I scroll this whole thing
using the mouse wheel, everything gets rendered nice and clean. On the
other hand, if I scroll by moving the scrollbar, the display kinda
waits until I let go before it repaints. This is more pronounced if I
scroll fast, it's reasonable when I scroll in small increments.

Is the Painting supressed when scrolling? I've done selective
optimization for some controls using ControlStyles.


Thanks!
 
I think you're using these smaller controls like simple graphical objects.
If you stop making that horrible mistake you'll start to see performance
like you need.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Thanks Bob, maybe you can comment on what is a good strategy based on
what I am trying to build below:

My requirement is to build a TV guide of sorts, 7 days horizontal,
24hrs vertical and populate the schedule with Programmes. The way I see
it, I could organize my UserControls as:

1. Organize it as a hierarchy of DaySchedule controls and keep adding
Programmes to it. The DaySchedule lays out the Prog internally in the
correct position based on Prog start times. This gives me a clean
structure, as each Prog entity needs to be selectable, have drag n
drop, menus etc and each Prog entity renders itself

2. Alternatively, instead of using Programme objects, i could just
maintain all data in the DaySchedule which displays Programs by
rendering all in one shot. In this way, getting the selected entity
under the mouse seems more difficult as there is no entity to speak of,
just a painted programme

...and this scrolling issue happens only when scrolling with scrollbars,
mouse wheel is fine.

Any thoughts?
 
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.windowsforms
Date: Sun, 15 Oct 2006 12:32:34 -0700
NNTP-Posting-Host: robbemorris.com 205.244.243.196
Lines: 1
Path: number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!msrtrans!TK2MSFTFEEDS01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
Xref: number1.nntp.dca.giganews.com microsoft.public.dotnet.framework.windowsforms:105840

I am dealing with this same issue. I have several panels that contain various textboxes, combo boxes, etc.. and when they scroll into view, it takes a while before they actually draw themselves. And until they do, the area that they occupy is just filled with whatever pixels happened to smear across it.

Is this a limitation of windows? A design flaw with user controls in the .net framework? Or am I simply overlooking something obvious?

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Back
Top