开发者

Coupling an MFC CListCtrl and CTreeCtrl to get a view of the whole tree, not just one node at a time

Consider Windows Explorer (or regedit or similar). To the left side, there is a tree view, and to the right, a list view. In all cases I know of, the contents of the right view reflect the attributes of the selected node from the left pane. This is all well and good... but just not what I want.

The nodes of the tree I want to display have a very few attributes (2-3) associated with each node - a reasonable amount to display horizontally as a row in a table. Rather than waste all that list view space on a single node with very few properties, I would like to have my list view display a table of the whole tree's properties (as the part of the tree currently expanded). So the nth line in the left view (tree) will correspond directly to the nth line in the ri开发者_如何学运维ght view (list/table), and I will get a decent overview of the properties of my tree.

Does anyone know of code that does this? I am guessing that slaving a CListCtrl to a CTreeCtrl would be the way to go, and somehow overriding the vertical scrolling functions so that they are locked together. I'm just not sure that it is possible to lock the scrolls together like this... among other things! All advice gratefully welcomed :-)


You are probably looking for Coumn Tree Control


If you make the list control owner-draw, it would be trivial to line it up with the tree control. However you still have the problem of two scroll bars that need to be synced. Perhaps you could capture the scroll events in one and copy them to the other.

Another option would be to skip the list control and use a header control to define your columns, and just draw the text as you need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜