procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
//循环读取勾选节点代码及内容
//StateIndex 1:unchecked(未选择) 2:checked(选择) 3:indeterminate(不确定的)
for i := to RzCheckTree1.Items.Count - do
begin
if RzCheckTree1.Items[i].StateIndex = 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 := to RzCheckTree1.Items.Count - do
begin
RzCheckTree1.Items[i].StateIndex := ;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
var
i: Integer;
begin
//全部取消选择
//StateIndex 1:unchecked(未选择) 2:checked(选择) 3:indeterminate(不确定的)
for i := to RzCheckTree1.Items.Count - do
begin
RzCheckTree1.Items[i].StateIndex := ;
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
i: Integer;
begin
//反选
//StateIndex 1:unchecked(未选择) 2:checked(选择) 3:indeterminate(不确定的)
for i := to RzCheckTree1.Items.Count - do
begin
if RzCheckTree1.Items[i].StateIndex = then
RzCheckTree1.Items[i].StateIndex :=
else
RzCheckTree1.Items[i].StateIndex := ;
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
var
i: Integer;
begin
//读取全部父节点
for i := to RzCheckTree1.Items.Count - do
begin
if RzCheckTree1.Items[i].Level = then
Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
i: Integer;
begin
//读取全部第二级子节点
for i := to RzCheckTree1.Items.Count - do
begin
if RzCheckTree1.Items[i].Level = then
Memo1.Lines.Add(RzCheckTree1.Items[i].Text);
end;
end;