How the MFC tree control hides the check boxes for the corresponding nodes

Source: Internet
Author: User

Sometimes you don't need a tree control all nodes display a check box, and then you need to hide the checkbox for the corresponding node, the code reads as follows:

M_treecontrol is the CTreeCtrl variable associated with the tree control, Nrootitem is the root node defined by Htreeitem;

M_treecontrol.setitemstate (nrootitem,indextostateimagemask (0), tvis_stateimagemask);//Hide root node check box


If you need to hide the checkbox of a node in the OnInitDialog () function of a class, you need to add the following two lines of code before the above code to take effect, otherwise it will not work:

Magic two lines of code	
m_treecontrol.modifystyle (tvs_checkboxes, 0);
M_treecontrol.modifystyle (0, tvs_checkboxes);
M_treecontrol.setitemstate (nrootitem,indextostateimagemask (0), tvis_stateimagemask);//Hide root node check box

The following figure is a picture of the check boxes for the first to second and three layers of a tree that I hide.



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.