CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013
    Posts
    1

    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.Name:  example.png
Views: 2220
Size:  10.0 KB

    TIA

  2. #2
    Join Date
    Feb 2013
    Posts
    1

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

    I have encountered a similar problem recently.
    I used a data table in conjunction with an array, but not linked by .NET. The data table is only for display purposes. So I kept its size limited to the number of rows and columns I can display, culling the stuff that scrolls off and adding the stuff that scrolls in from the array.

    It is a bit of work, but the table remains small and fast.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured