Is there a way to do a LoadOnDemand for a TreeNode on a Windows Form?

  • Thread starter Thread starter John Heitmuller.
  • Start date Start date
J

John Heitmuller.

Is there a standard approach to loading TreeNodes only when they are
expanded in the WinForm version of the 2.0 Framework?

I need to display large amount of data in a Windows Form TreeView
control. The data takes several minutes to load into the tree. I
noticed that the ASP.NET 2.0 TreeNode control as a LoadOnDemand
feature that would solve my problems. However, that feature does not
seem to be available for the WinForm version of the TreeNode class. I
feel like I'm missing something here.

I tried to derive a class from System.Windows.Forms.TreeNode and
override the Expand() method, but apparently Expand is not
overrideable.

Any suggestions on how to approach this?

Thanks,
John
 
John Heitmuller. said:
Is there a standard approach to loading TreeNodes only when they are
expanded in the WinForm version of the 2.0 Framework?

I need to display large amount of data in a Windows Form TreeView
control. The data takes several minutes to load into the tree. I
noticed that the ASP.NET 2.0 TreeNode control as a LoadOnDemand
feature that would solve my problems. However, that feature does not
seem to be available for the WinForm version of the TreeNode class. I
feel like I'm missing something here.

I tried to derive a class from System.Windows.Forms.TreeNode and
override the Expand() method, but apparently Expand is not
overrideable.

Any suggestions on how to approach this?

Thanks,
John

John,

The "easiest" method is to create the top level node(s) and under each
one of them a "dummy" node so that the (+) plus sign will show. Then when
you handle the expand event you will check if the node present is a "dummy"
node and if so then delete the "dummy" node and populate that node with its
child nodes. You can do the same if the treeview has many levels.

If there are no nodes deleting the "dummy" node will make the (+) plus
sign go away.

Hope this helps
Lloyd Sheen
 
Hi LIoyd, yes the dummy nodes were part of the solution. I also found
the BeforeExpand event on the TreeView control which was where I
needed to put my code the load the nodes. Thanks.
 
Back
Top