应该按结构读到TreeView里。
procedure TForm1.AddItem(MenuItem: TMenuItem;
Node: TTreeNode);
var i: integer;
ChildNode: TTreeNode;
begin
ChildNode := TreeView1.Items.AddChild(Node, MenuItem.Caption);
for i := 0 to MenuItem.Count - 1do
AddItem(MenuItem.Items, ChildNode);
end;
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
for i := 0 to MainMenu1.Items.Count-1do
AddItem(MainMenu1.Items, nil);
end;
注意把读出的Caption中的'&'去掉。