January 8th, 2013, 11:29 AM
How can I fake a grid in .NET with the scrolling speed of Excel?
Firstly, this is a legacy system and I am not responsible for it's existence, just its maintenance and enhancement.
I have a large VB.NET app that generates a grid using label controls. The reason for using label controls rather than a datagrid is because the cells are of varying width both within a row and across rows, something Excel cannot directly do (yes, I could mess around with merge cells etc). On screen you see 40 'rows' (subject to screen res) and about 13 'columns', but could be far more, there could 1000+ data rows, even 10,000+ to display/scroll through.
Label controls are created as needed and recycled, when the user scrolls the controls are jiggled into their new positions, unused controls are hidden. Right-click menus and drag drop are used. The controls are hosted within a panel control which is in a tab page, there could be several such tab pages at once.
Scrolling is painfully slow, it can take 2-3s on a 8 core Xeon with fairly modern NVidia graphics. Using the VS 2010 profiler nearly all of the time in scrolling is spent setting the Left and Width property of the controls. As a test I compared a VB.NET app randomly moving 1000 labels to a C API app, the API app was twice as fast. This shows the bottleneck is not an inherent problem in Windows but .NET. I am not allowed to use the API however.
So far I have disabled redrawing using this http://dotnet.mvps.org/dotnet/faqs/?...rawing&lang=en and suspended the layout of the parent panel (which seems fairly ineffective).
If I were to go back to the drawing board, how could I generate the required layout and support right-click menus and drag drop and instant scrolling?
.NET apps cannot create more than 10,000 controls so creating everything up front is not a realistic option, tried that too.
Attached a censored screenshot showing the layout, clearer than my description.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!