procedure ToggleTreeViewCheckBoxes( Node :TTreeNode; cUnChecked, //CheckBox未选中状态 cChecked, //CheckBox选中状态 cRadioUnchecked, //RadioButtion未选中状态 cRadioChecked :integer); // RadioButtion选中状态 var tmp:TTreeNode; begin if Assigned(Node) then begin //如果当前是未选中状态则变为选中状态 if Node.StateIndex = cUnChecked then Node.StateIndex := cChecked //如果当前是选中状态则变为未选中状态 else if Node.StateIndex = cChecked then Node.StateIndex := cUnChecked else if Node.StateIndex = cRadioUnChecked then begin tmp := Node.Parent; if not Assigned(tmp) then tmp := TTreeView(Node.TreeView).Items.getFirstNode else tmp := tmp.getFirstChild; while Assigned(tmp) do begin if (tmp.StateIndex in [cRadioUnChecked,cRadioChecked]) then tmp.StateIndex := cRadioUnChecked; tmp := tmp.getNextSibling; end; Node.StateIndex := cRadioChecked; end; // if StateIndex = cRadioUnChecked end; // if Assigned(Node) end; |