TO:SUNYS 这是我改后的,你看有没有更有效的方法,总觉得很效率不高!
procedure TF_HouseDown.tvHouseToggleCheckbox(TreeView: TfcCustomTreeView;
Node: TfcTreeNode);
var Parentnode,Nodes,Node1:tfctreenode;
bNodeAllCheck,bNodeNotAllCheck,bNodeAllNotCheck:boolean;
begin
if not isActive then exit;
isActive:=False;
Nodes:=Node;
Parentnode:=Nodes.Parent;
while Parentnode<>nil do
begin
Node1:=Parentnode.GetFirstChild;
bNodeAllCheck:=True;
Node1:=Parentnode.GetFirstChild;
while Node1 <> Nil do
begin
if not (Node1.Checked) or (Node1.Grayed) then
begin
bNodeAllCheck:=False;
break;
end;
Node1:=Parentnode.getNextChild(Node1);
end;
bNodeAllNotCheck:=True;
Node1:=Parentnode.GetFirstChild;
while Node1 <> Nil do
begin
if (Node1.Checked) then
begin
bNodeAllNotCheck:=False;
break;
end;
Node1:=parentnode.getNextChild(Node1);
end;
if bNodeAllCheck then
begin
Parentnode.Checked:=True;
Parentnode.Grayed:=False;
end else if bNodeAllNotCheck then
begin
Parentnode.Checked:=False;
Parentnode.Grayed:=False;
end else if (not bNodeAllNotCheck) and (not bNodeAllCheck) then
begin
Parentnode.Checked:=True;
Parentnode.Grayed:=True;
end;
Parentnode:=Parentnode.Parent;
end;
NodeChildCheckfalse(Nodes);
isActive:=true;
end;
procedure TF_HouseDown.NodeChildCheckfalse(Nodes:tfctreenode);
var ChildNode:tfctreenode;
begin
ChildNode:=Nodes.getFirstChild;
while ChildNode<>nil do
begin
Childnode.Checked:=Nodes.Checked;
Childnode.Grayed:=False;
NodeChildCheckfalse(ChildNode);
ChildNode:=Nodes.getNextChild(ChildNode);
end;
end;