سؤال

we have a TTreeView that has many nodes - typically 20,000 nodes and more. This TTreeView is used in a docked interface (DevExpress Docking Library). When any form in the application is docked or undocked, the dockable form's handles are changed. This in turn results in the DestroyWnd and CreateWnd procedure of all forms and controls being called.

In the case of a TTreeView, DestroyWnd saves the nodes to a stream and CreateWnd reloads them. In our application with a very large treeview this results in a long delay while the nodes are streamed out and and back in.

My question: how to prevent this delay? I have heard many people speak highly of Virtual TreeView which I believe is not descended from TTreeView, does it avoid this issue? We have tried the Developer Express TcxTreeView, but it descends from TTreeview so it suffers from the same problem.

هل كانت مفيدة؟

المحلول

20,000 nodes is way too many to put into a standard TTreeView. Using TVirtualTreeView is definately the way to go for displaying a large number of nodes. The main advantage is that your node data is not stored in the TreeView itself. It is just used for display and user interaction. You store your data elsewhere in memory so it is unaffected by window recreations, and then TVirtualTreeView asks you for just the pieces of data it immediately needs at any give time. Recreating the TVirtualTreeView window is just a matter of repainting the window display with the current data.

Unlike with a standard TTreeView, which stores the data in the TreeView itself. That is why TTreeView.DestroyWnd() and TTreeView.CreateWnd() have to save and restore a copy of all the node data every time the window is recreated. The more nodes there are, the more overhead there is to manage that data.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top