TreeView设置节点图标_子节点

 

 

没子节点的设置其图标为 0
有节点的设置其图标为 1
procedure TForm1.Button1Click(Sender: TObject);
var
   i:Integer;
begin
    with TreeView1 do
    begin
      for i:= 0 to Items.Count -1 do
      begin
         if Items[i].HasChildren then
            begin
              Items[i].ImageIndex:=0;
              Items[i].SelectedIndex:=0;
              Items[i].StateIndex:=0;
            end
         else
            begin
              Items[i].ImageIndex:=1;
              Items[i].SelectedIndex:=1;
              Items[i].StateIndex:=1;
            end;
      end;
    end;
end;