通过编程方式更改子节点时,如何自动更新父节点的CheckState? [英] How to Auto Update the CheckState of the parent nodes When Child's Changed Programmingly?

查看:49
本文介绍了通过编程方式更改子节点时,如何自动更新父节点的CheckState?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Delphi XE3与Virtual TreeView一起使用.

I am using Delphi XE3 with Virtual TreeView.

我已启用toAutoTristateTracking选项.

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;

PNode^.CheckState := csCheckedNormal;

仅PNode检查状态将被更改.受影响的节点将不会更改其状态.为什么?

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

推荐答案

不直接访问节点的 CheckState .使用 TBaseVirtualTree 的数组属性 CheckState [Node:PVirtualNode] 读取/写入检查状态.通过该属性设置检查状态将应用与复选框相关的功能,并触发相应的事件,例如 OnChecking OnChecked OnInitNode ,...

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, ...

这应该改为:

VirtualStringTree1.CheckState[PNode] := csCheckedNormal;

这篇关于通过编程方式更改子节点时,如何自动更新父节点的CheckState?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆