How to Auto Update the CheckState of the parent nodes When Child's Changed Programmingly?

a 夏天 提交于 2021-02-08 09:12:59

问题


I am using Delphi XE3 with Virtual TreeView.

I have enabled the toAutoTristateTracking option.

WHen I try to change the check state of a node manually, then the affected node's checkstate will change as well.

However, when I do the same thing programmingly, for example

PNode^.CheckState := csMixedNormal;

or

PNode^.CheckState := csCheckedNormal;

Only PNode check state will be changed. The affected nodes will not change their states. Why?


回答1:


Don't access CheckState of a node directly. Use array property CheckState[Node: PVirtualNode] of TBaseVirtualTree to read/write check state. Setting check state via the property will apply functionality related to tick boxes as well as fire appropriate events like OnChecking, OnChecked, OnInitNode, ...

This is what you should do instead:

VirtualStringTree1.CheckState[PNode] := csCheckedNormal;


来源:https://stackoverflow.com/questions/58058639/how-to-auto-update-the-checkstate-of-the-parent-nodes-when-childs-changed-progr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!