RzCheckTree基本使用

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  //循环读取勾选节点代码及内容
  //StateIndex 1:unchecked(未选择) 2:checked(选择)  3:indeterminate(不确定的)
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    if RzCheckTree1.Items[i].StateIndex = 2 then
    begin
      //VarToStr(RzCheckTree1.Items[i].Index);  //读取节点标识序号
      //RzCheckTree1.Items[i].Text;             // 读取节点值
      Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
    end;

//    另一种判断方式
//    if RzCheckTree1.ItemState[i] = csChecked then
//    begin
//      Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
//    end;
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  //展开全部节点
  RzCheckTree1.FullExpand;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
  //关闭全部节点
  RzCheckTree1.FullCollapse;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
  i: Integer;
begin
  //全部选择
  //StateIndex 1:unchecked(未选择) 2:checked(选择)  3:indeterminate(不确定的)
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    RzCheckTree1.Items[i].StateIndex := 2;
  end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
  i: Integer;
begin
  //全部取消选择
  //StateIndex 1:unchecked(未选择) 2:checked(选择)  3:indeterminate(不确定的)
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    RzCheckTree1.Items[i].StateIndex := 1;
  end;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
  i: Integer;
begin
  //反选
  //StateIndex 1:unchecked(未选择) 2:checked(选择)  3:indeterminate(不确定的)
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    if RzCheckTree1.Items[i].StateIndex = 1 then
      RzCheckTree1.Items[i].StateIndex := 2
    else
      RzCheckTree1.Items[i].StateIndex := 1;
  end;
end;
procedure TForm1.Button7Click(Sender: TObject);
var
  i: Integer;
begin
  //读取全部父节点
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    if RzCheckTree1.Items[i].Level = 0 then
      Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
  end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
  i: Integer;
begin
  //读取全部第二级子节点
  for i := 0 to RzCheckTree1.Items.Count - 1 do
  begin
    if RzCheckTree1.Items[i].Level = 1 then
      Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
  end;
end;

 

posted @ 2017-07-17 14:50  liessay  阅读(979)  评论(0编辑  收藏  举报