none
Treeview with large number of nodes (> 500) taking long time to load RRS feed

  • Question

  • Hi,
    I am having a treeview with more than 500 nodes - probably may go up to 1000. Whenever I start my application , it takes quite a bit of time to load all the items in the treeview. I have noticed the scrollbar moves all the way from top to bottom and then back to top before displaying all the items. Is there any way to speed up this process?

    Thanks.

    Theo
    Friday, June 6, 2008 9:47 AM

Answers

  • You could not use background threads with GUI since you can only touch controls from UI thread.

     

    All list controls but DataGrid would have performance issues with large number of items. You should populate your tree view dynamically to avoid it. E.g. add top level nodes first, add sub nodes only as top level nodes are expanded.

     

    If you can use DataGrid with data binding instead, it would only fetch visible rows.

     

    Friday, June 6, 2008 4:39 PM
    Moderator

All replies

  • Hello

    even if you gererate 500 node in windows application also it's should take time man,

    so plese use background thread do with delegate

    build your tree view.

    that 's must fast than normal way.

    Thank you
    Friday, June 6, 2008 2:04 PM
  • You could not use background threads with GUI since you can only touch controls from UI thread.

     

    All list controls but DataGrid would have performance issues with large number of items. You should populate your tree view dynamically to avoid it. E.g. add top level nodes first, add sub nodes only as top level nodes are expanded.

     

    If you can use DataGrid with data binding instead, it would only fetch visible rows.

     

    Friday, June 6, 2008 4:39 PM
    Moderator
  • Thanks. Will try DataGrid.
    Saturday, June 7, 2008 5:26 AM
  • Hello Sir    Ilya Tumanov

    i didn't meet update UI bye the background thread in my prevoius post, i told do all process except build the GUI, by the external Backgroundworker, then finally when that is task completed use th completed event in BGW and update the GUI.

    Thank you
    Sunday, June 8, 2008 4:57 AM
  • Hi , you can simply use following code that will help you in solving your problem:--



    MyTree.SuspendLayout();

    // Fill your tree
    // Then Write following Code

    tr_MyTree.ResumeLayout(false);
    tr_MyTree.PerformLayout();


    i hope this will help you


    Pr.wa'el
    • Proposed as answer by Wa'el Saturday, January 24, 2009 11:54 AM
    Tuesday, December 16, 2008 11:07 AM
  • Using the BeginUpdate() and EndUpdate() functions solved a similar problem for me.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.beginupdate.aspx

    Friday, August 16, 2013 1:04 PM