1.   判断状态:  
   
  if   RzCheckTree1.Selected.StateIndex   =   2   then  
      //则为选中状态  
  else   if   RzCheckTree1.Selected.StateIndex   =   1   then  
      //则为未选中状态  
  else   if   RzCheckTree1.Selected.StateIndex   =   3   then  
      //则为未全选状态  
   
  或者  
   
  if   RzCheckTree1.ItemState[I]   =   csUnchecked   then   //为未选中状态  
  if   RzCheckTree1.ItemState[I]   =   cschecked   then   //为选中状态  
   
   
  2:   设置  
   
  RzCheckTree1.ItemState[I]   :=   csUnchecked     //为未选中状态  
  RzCheckTree1.ItemState[I]   :=   cschecked     //为选中状态  

权限树的创建

procedure CreatePermissionsTree(DataSet: TADOQuery; Tree: TRzCheckTree;
  const TableName, aid, aname, quanXian: string);
const
  ID_DEPT = 2;
var
  nLevel: Integer;
  pNodes: array[0..1023] of TTreeNode;
  lpid, lpName, s: string;
begin
  if DataSet = nil then Exit;
  if Tree = nil then Exit;
  if TableName = '' then Exit;
  pNodes[0] := nil;
  Tree.Items.Clear;
  with DataSet do
  begin
    Close;
    SQL.Clear;
    s := Format('select * from %s order by %s', [TableName, aid]);
    SQL.Text := s;
    Open;
    if IsEmpty then Exit;
    First;
    while not Eof do
    begin
      lpid := FindField(aid).AsString;
      lpName := FindField(aname).AsString;
      nLevel := Length(lpID) div ID_DEPT;

      pNodes[nLevel] := Tree.Items.AddChild(pNodes[nLevel - 1], lpName);
      if FindField('quanxian').AsBoolean then
        pNodes[nLevel].StateIndex := 2
      else pNodes[nLevel].StateIndex := 1;
      Next;
    end;
  end;
end;