是否可以从树视图的节点中删除一些复选框? [英] Is it possible to remove some checkboxes from tree view's nodes?
问题描述
我已经使用资源编辑器在对话框中进行了树视图控制。
I have made a tree view control in dialog box, using resource editor.
我已经使用SetWindowLongPtr(...)函数设置了复选框样式, Microsoft描述。
I have set the checkbox style with SetWindowLongPtr( ... ) function, the way Microsoft described.
每个节点都有复选框,但我只需要一些复选框,有些没有站在他们的文本旁边复选框,只有孩子或简单的 - >没有孩子的人)。
Every node has checkbox this way, yet I need only some to have checkbox, and some to have nothing standing next to their text ( parent nodes do NOT have checkbox, only child or simple ones->ones without children ).
这可以通过子类化或者定制/所有者绘制或者超级类>
Can this be achieved by subclassing, or maybe with custom/owner draw or perhaps superclassing ?
推荐答案
树控件使用状态图像绘制复选框。根据 TVS_CHECKBOXES
样式的文档:
The tree control uses state images to draw the checkboxes. According to the docs on the TVS_CHECKBOXES
style:
状态图像1是未选中框和状态图像2是检查的
框。将状态图片设置为零会删除此复选框。
State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to zero removes the check box altogether.
因此,应该允许您从树项中删除复选框:
So something like this should let you remove the check box from a tree item:
TVITEM tvi;
tvi.hItem = hTreeItem;
tvi.mask = TVIF_STATE;
tvi.stateMask = TVIS_STATEIMAGEMASK;
tvi.state = 0;
TreeView_SetItem(hWndTree, &tvi);
这篇关于是否可以从树视图的节点中删除一些复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!