How can I fake a grid in .NET with the scrolling speed of Excel?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa Firstly, this is a legacy system and I am not responsible for its existence, just its maintenance and
enhancement.<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa 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.<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa 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.<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa 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.<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa So far I have disabled redrawing using this http://dotnet.mvps.org/dotnet/faqs/?id=disableredrawing&lang=en " target="_blank" style="color:#0033cc; text-decoration:initial; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa http://dotnet.mvps.org/dotnet/faqs/?...rawing&lang=en <span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa and
suspended the layout of the parent panel (which seems fairly ineffective).<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa 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?<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa .NET apps cannot create more than 10,000 controls so creating everything up front is not a realistic option,
tried that too.<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa Attached a censored screenshot showing the layout, clearer than my description.<img alt="Name: example.png
Views: 1
Size: 10.0 KB" border="0" src="http://forums.codeguru.com/attachment.php?attachmentid=30815&d=1357662566" title="Name: example.png
Views: 1
Size: 10.0 KB" style="border:0px; max-width:800px; color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa <br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<br style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa
<span style="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; line-height:normal; background-color:#fafafa TIA

View the full article
 
Back
Top