耦合 MFC CListCtrl 和 CTreeCtrl 以获取整个树的视图,而不仅仅是一次一个节点

发布于 2024-09-03 03:22:40 字数 408 浏览 9 评论 0原文

考虑 Windows 资源管理器(或 regedit 或类似的)。左侧是树视图,右侧是列表视图。在我所知的所有情况下,右视图的内容反映了左窗格中所选节点的属性。这一切都很好……但不是我想要的。

我想要显示的树的节点具有与每个节点关联的很少的属性(2-3) - 在表中水平显示为一行的合理数量。我不想将所有列表视图空间浪费在具有很少属性的单个节点上,而是希望让列表视图显示整个树属性的表格(作为当前展开的树的一部分)。因此,左视图(树)中的第 n 行将直接对应于右视图(列表/表)中的第 n 行,并且我将获得树属性的一个不错的概述。

有谁知道执行此操作的代码?我猜测将 CListCtrl 从属于 CTreeCtrl 将是可行的方法,并以某种方式覆盖垂直滚动功能,以便将它们锁定在一起。我只是不确定是否可以像这样将卷轴锁定在一起......除其他外!非常欢迎所有建议:-)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

海风掠过北极光 2024-09-10 03:22:40

您可能正在寻找Coumn Tree Control

You are probably looking for Coumn Tree Control

暖心男生 2024-09-10 03:22:40

如果将列表控件设置为所有者绘制,则将其与树控件对齐就很简单了。但是,您仍然遇到两个滚动条需要同步的问题。也许您可以捕获其中一个中的滚动事件并将它们复制到另一个中。

另一种选择是跳过列表控件并使用标题控件来定义列,然后根据需要绘制文本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文