遍历mainmenu显示到treeview时出现点问题,那位高手给看看(10)

  • 主题发起人 主题发起人 zhk7324385
  • 开始时间 开始时间
Z

zhk7324385

Unregistered / Unconfirmed
GUEST, unregistred user!
如mainmenu中是 aa bb cc dda1 b1 c1a2 b2-a3treeview中应该为-aa a1 a2 - a3-bb b1 b2+ccdd 我是这么写的,但是结果不太对,所有的字节点都跑到aa下了结果treeview中成了:-aa a1 a2 - a3 b1 b2 c1bbccdd 那位高手给看看怎么这么改改var node:ttreenode; s:string; i,m:integer;begin TreeView1.Items.Clear; //加入权限列表 i:=0 ; while i<=mm1.Items.Count-1 do begin treeview1.items.Add(nil,mm1.items.Caption); //node:=treeview1.Items.Item; node:=treeview1.Items.GetFirstNode; // node:=treeview1. m:=0 ; while m<=mm1.Items.Items.Count-1 do begin if (Form1.mm1.Items.Items.Items[m].Caption<>'-') and (Form1.mm1.Items.Items.Items[m].Visible ) then TreeView1.Items.AddChild(node,mm1.items.Items[m].Caption); m:=m+1 end; i:=i+1;end;
 
procedure TForm1.CreatMyTree(aitem: TMenuItem; node: TTreeNode);Var I: Integer; anode: TTreeNode;Begin If aitem <> Nil Then Begin For I := 0 To aitem.Count - 1 Do Begin With aitem Do Begin if (length(Caption) >0) And (Not SameText(Caption, '-')) And (Visible) then Begin anode := TreeView1.Items.AddChild(node, Caption); If Count > 0 Then CreatMyTree(aitem, anode); End; End; End; End;End;procedure TForm1.FormCreate(Sender: TObject);var node:ttreenode; i:integer;begin TreeView1.Items.BeginUpdate; TreeView1.Items.Clear; try for i := 0 to mm1.Items.Count - 1 Do Begin node := TreeView1.Items.Add(Nil, mm1.Items.Caption); CreatMyTree(mm1.Items, node); End; finally TreeView1.Items.EndUpdate; end;end;
 
接受答案了.
 
后退
顶部