Three-State selection tree Implementation terminator

Source: Internet
Author: User
Tags knowledge base

The sample code runs as shown below:

In many cases, we often need to implement a tree's polymorphic selection, as shown in the figure above, when all child nodes are selected, the current node is selected (such as the diagram [Jingmen] node) and the current node is in a third state when the child node is partially selected (for example, the [Hubei Province] node) when all child nodes are not selected The current node is in an unchecked state (such as the diagram [Jiangsu Province] node). In this paper, we introduce the method of realizing the three-state selection tree.

In the VC Knowledge Base phase 19th, Henan University of Science and Technology Conre Friends also introduced a method of implementation, the two methods are compared, the method introduced in this article is simple, compatible with the original CTreeCtrl all operations, checkbox is also the control itself to use the checkbox, only in the state of the display when the redraw. Therefore, this method can display the icon of the node icon in the case of three states, and also increase the control of whether the checkbox is displayed at some nodes, while the control of selecting and canceling the keyboard space bar is increased. The method of traversing the parent and child nodes is similar to the method of Conre friend friend, and it is recursive to realize the traversal of all nodes, but it is optimized some more efficiently.

Here's how to use this:

Step one: Generate a dialog box Project (sample Engineering Cmutitree).

Step Two: Add the tree control and set the desired properties as needed.

Step three: Make the node icon and the three-State selection box icon

In general, the node icon using 16x16, three-state selection icon to use the 13x13 size is more appropriate.

Three-State selection icon corresponds to: 0-> No selection button 1-> did not select the 2-> part of the selection 3-> all selected

Step four: Add two files [MutiTreeCtrl.cpp, MutiTreeCtrl.h] to the dialog box created by step one

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.