tags:

views:

45

answers:

2

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 right 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 :-)

A: 

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.

Mark Ransom
Perhaps you could elaborate, or point to example code. Somehow I don't think "owner draw" and "trival" belong in the same sentence... In any case, there is surely no need for owner draw - each expansion or contraction of the tree uniquely defines what should go into the list view. So long as font sizes are chosen to keep the spacing even, MFC will draw it all for me. It's really just syncing the scrolling that is the issue, is it not?
omatai
A: 

You are probably looking for Coumn Tree Control

Jujjuru
Exactly - thanks. A compelling answer :-)
omatai