CTreeCtrl 树状控件显示展开和折叠的按钮“+/-”

让树状控件显示展开和折叠的按钮其实是很简单的,把 Style 设置成TVS_HASBUTTONS就可以了。不过你可能会发现根节点却没有展开折叠按钮,咋回事呢?折腾半天也没作用,还是看看MSDN的文档吧。

TVS_HASBUTTONS
Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item’s list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified.

呵呵,注意到了吧,最后一句,还需要 TVS_LINESATROOT。这就够了吗?再看看 TVS_LINESATROOT

TVS_LINESATROOT
Uses lines to link items at the root of the tree-view control. This value is ignored if TVS_HASLINES is not also specified.

如果 TVS_HASLINES 没有设置,那么 TVS_LINESATROOT将会被忽略,所以也别忘了 TVS_HASLINES。再看TVS_HASLINES。

TVS_HASLINES
Uses lines to show the hierarchy of items.

看来不需要其他的了,试一试,可以了吧。呵呵。

Posted by 王永杰 in C&C++
14 04月

没有评论 »

还没有评论。

发表评论

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word