Partial display of Treeview checkbox

Source: Internet
Author: User

If you have used Asp.net, you should know that to implement the above functions in the Treeview, you can use the showcheckbox attribute to specify the nodes that display the checkbox and do not display it. However, the Treeview in winform only provides one showcheckboxes attribute, either all nodes display the checkbox or none, but the specified node does not have the showcheckbox attribute. The following describes how to implement the checkbox attribute of Bs in the Treeview of winform.

A) set the checkboxs attribute of Treeview to false.

B) associate the stateimagelist attribute of the Treeview with an imagelist component. Add the checkbox option to the component, select the image, and select the unselected image.

C) add the nodemouseclick event of the Treeview and use E. node. you can create a generic set, such as list <string>, to store the node items that have been checked, in this way, you can easily switch between the indexed image and the indexed image.

D) Disadvantage: The nodemouseclick event is triggered at any position in the row where the node in the click tree is located. Because the treeviewmediaaftercheck and treeviewmedianodemouseclick events cannot be triggered, only nodemouseclick events can be used.

E) Principle: In winform, the checkbox items of Treeview are actually displayed using images. The selected images are hook-up images, but not those that are not checked, associated with the stateimagelist attribute (empty by default, use the built-in image ). Therefore, if you want to implement the specified treenode to display the checkbox, you need to use the stateimagelist attribute of treenode if the other treenode does not display the checkbox.

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.