如何在节点中显示或隐藏树视图复选框? [英] How to show or hide tree view checkboxes in nodes ?

查看:172
本文介绍了如何在节点中显示或隐藏树视图复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

首先,我要感谢所有花一些时间来查看此主题并尝试提供帮助的人.


我已经使用资源编辑器在对话框中创建了树形视图控件.

我已经使用SetWindowLongPtr(...)函数设置了复选框样式.

每个节点都有复选框,但我只需要其中一个复选框即可,而有些则不需要在其文本旁放置任何内容.

可以通过子类化来实现,如果可以,请给我一些指针或链接,可能还提供示例代码或教程.

如果无法通过子类化完成,那么请向我指出正确的方法(例如自定义绘图或超类?).

我使用 WIN32 API在Windows XP和C ++中的MS Visual Studio Express 2008中工作.

Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.


I have made a tree view control in dialog box, using resource editor.

I have set the checkbox style with SetWindowLongPtr( ... ) function.

Every node has checkbox, yet I need only some to have checkbox, and some to have nothing standing next to their text.

Can this be achieved by subclassing, and if it can, please give me some pointers or links, possibly sample code or tutorials.

If it can''t be done by subclassing, then please point me to the right direction on how to do it ( maybe custom draw or perhaps superclassing ? ).

I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.

Thank you very very much!

推荐答案

检查一下- ^ ]


在进行了OP的澄清之后:一种解决方案是删除节点并再次添加该节点,这次是删除或添加了复选框.如果有子代,则应保留并还原整个子集.第二种解决方案是使用自定义绘制并模拟图形中的复选框,并对所有必需的事件进行编程.使节点无效,并删除(隐藏),禁用或其他任何复选框.

—SA
After OP''s clarifications: one solution is to remove the node and add it again, this time with check box removed or added. If it has children, the whole child set should be preserved and restored. Second solution is to use custom draw and simulate a check box in graphics and program all required events. Invalidate the node and get check box removed (hidden), disabled, or anything.

—SA


有人可以通过两种方式执行此操作:

一种方法是模拟复选框,如解决方案1和2所建议的那样,另一种方法是这样做的:

创建树视图控件后,添加一个项目,获取该项目的句柄,然后按照以下描述的方式设置项目状态:

http://stackoverflow.com/questions/17798463/is-it-possible-to-move-some-checkboxes-from-tree-views-nodes [
There are two ways somebody can do this:

One is to simulate checkboxes, as it is suggested in solutions 1 and 2, and other is to do it this way:

After creating tree view control, add an item, get this items handle, and then set items state the way it is described here:

http://stackoverflow.com/questions/17798463/is-it-possible-to-remove-some-checkboxes-from-tree-views-nodes[^]


这篇关于如何在节点中显示或隐藏树视图复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆