rzchecktree实现单选以及隐藏选择框 https://blog.csdn.net/weixin_34290631/article/details/89804683
2017年11月15日 19:45:00 AirZH?? 阅读数 5
1,定义公共树节点node——select andselect_index,用来保存当前选中节点
casecadechecks设为false
2.方法如下
stateindex = 1代表没选中,stateindex = 2,代表选中
tree_checker.ItemState[i] := csUnknown代表没有选择框。
procedure Tfrm_w_checker.tree_checkerClick(Sender: TObject);
var
i:integer;
flag :string;
begin
node_select := tree_checker.Selected;
i := node_select.AbsoluteIndex;
if (node_select.Level = 1) then
begin
node_select.StateIndex := 2;
doctor := PNodedata(node_select.Data)^.doctor;
end;
if (node_select.Level = 1) and (node_select.StateIndex = 2) then
begin
if (select_index <> 0) and (select_index <> node_select.AbsoluteIndex) then
begin
tree_checker.Items[select_index].StateIndex := 1;
end;
select_index := node_select.AbsoluteIndex;
end;
for i := 0 to tree_checker.Items.Count - 1 do
begin
if tree_checker.Items[i].Level = 0 then
tree_checker.ItemState[i] := csUnknown;
end;
end;