々
々^丫y
Unregistered / Unconfirmed
GUEST, unregistred user!
//第一个,第二个,是用来遍历树
//第三个根据TYPE的值进行添加图标
//但加上不,IMAGEINDEX的值一直是-1,但用Item.Text[0]:='AAA',可以更改标题
//为什么加不上图标,请高手赐教
procedure TMainFrm.Create_FunctionTree;
var
i:Integer;
begin
i:=0;
while (i <self.cxDBTreeList1.Count)do
begin
self.cxDBTreeList1.Items.Focused:=True;
self.Set_TreeImage(self.cxDBTreeList1.Items,Trim(self.cxDBTreeList1.DataController.DataSet.fieldbyname('Type').AsString));
if self.cxDBTreeList1.Items.Count>0 then
begin
self.Child_Tree(self.cxDBTreeList1.Items);
end;
i:=i+1;
end;
end;
procedure TMainFrm.Child_Tree(Item:TcxTreeListNode);
var
i:Integer;
begin
i:=0;
showmessage(inttostr(Item.Count));
while(i <Item.Count)do
begin
Item.Items.Focused:=True;
self.Set_TreeImage(self.cxDBTreeList1.Items,Trim(self.cxDBTreeList1.DataController.DataSet.fieldbyname('Type').AsString));
if Item.Items.Count>0 then
begin
self.Child_Tree(Item.Items);
end;
i:=i+1;
end;
end;
procedure TMainFrm.Set_TreeImage(Item:TcxTreeListNode;Type_:String);
begin
if Type_='A' then
Item.ImageIndex:=1;
if Type_='B' then
Item.ImageIndex:=2;
end;
procedure TMainFrm.dxBarButton6Click(Sender: TObject);
begin
YPMISClient_DM.Sys_FunctionTreeDt.Open;
self.Create_FunctionTree;
end;
//第三个根据TYPE的值进行添加图标
//但加上不,IMAGEINDEX的值一直是-1,但用Item.Text[0]:='AAA',可以更改标题
//为什么加不上图标,请高手赐教
procedure TMainFrm.Create_FunctionTree;
var
i:Integer;
begin
i:=0;
while (i <self.cxDBTreeList1.Count)do
begin
self.cxDBTreeList1.Items.Focused:=True;
self.Set_TreeImage(self.cxDBTreeList1.Items,Trim(self.cxDBTreeList1.DataController.DataSet.fieldbyname('Type').AsString));
if self.cxDBTreeList1.Items.Count>0 then
begin
self.Child_Tree(self.cxDBTreeList1.Items);
end;
i:=i+1;
end;
end;
procedure TMainFrm.Child_Tree(Item:TcxTreeListNode);
var
i:Integer;
begin
i:=0;
showmessage(inttostr(Item.Count));
while(i <Item.Count)do
begin
Item.Items.Focused:=True;
self.Set_TreeImage(self.cxDBTreeList1.Items,Trim(self.cxDBTreeList1.DataController.DataSet.fieldbyname('Type').AsString));
if Item.Items.Count>0 then
begin
self.Child_Tree(Item.Items);
end;
i:=i+1;
end;
end;
procedure TMainFrm.Set_TreeImage(Item:TcxTreeListNode;Type_:String);
begin
if Type_='A' then
Item.ImageIndex:=1;
if Type_='B' then
Item.ImageIndex:=2;
end;
procedure TMainFrm.dxBarButton6Click(Sender: TObject);
begin
YPMISClient_DM.Sys_FunctionTreeDt.Open;
self.Create_FunctionTree;
end;