代码实现不同的子节点图标效果。
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ImgList, ComCtrls, XPMan; type TForm1 = class(TForm) TreeView1: TTreeView; ImageList1: TImageList; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var node1: TTreeNode; begin node1 := treeView1.Items.AddFirst(nil, '全部待办事宜'); node1.ImageIndex := 1; node1.SelectedIndex := 1; node1 := treeView1.Items.AddChildFirst(node1, '问问'); node1.ImageIndex := 1; node1.SelectedIndex := 1; node1 := treeView1.Items.AddChild(node1.Parent, '1114'); node1.ImageIndex := 1; node1.SelectedIndex := 1; node1 := treeView1.Items.AddChild(node1.Parent.Parent, '进度状态'); node1.ImageIndex := 1; node1.SelectedIndex := 1; node1 := treeView1.Items.AddChildFirst(node1, '未处理'); node1.ImageIndex := 0; node1.SelectedIndex := 0; node1 := treeView1.Items.AddChild(node1.Parent, '正在处理'); node1.ImageIndex := 0; node1.SelectedIndex := 0; node1 := treeView1.Items.AddChild(node1.Parent, '已完成'); node1.ImageIndex := 0; node1.SelectedIndex := 0; node1 := treeView1.Items.AddChild(node1.Parent.Parent, '更新时间'); node1.ImageIndex := 1; node1.SelectedIndex := 1; node1 := treeView1.Items.AddChildFirst(node1, '今天更新'); node1.ImageIndex := 0; node1.SelectedIndex := 0; end; end.