procedure TForm1.AddButtonClick(Sender: TObject); var index: Integer; NewItem: TMenuItem; begin for index := 0 to 3 do begin NewItem := TMenuItem.Create(PopupMenu1); // create the new item PopupMenu1.Items.Add(NewItem);// add it to the Popupmenu NewItem.Caption := 'Menu Item ' + IntToStr(index); NewItem.Tag := index; NewItem.OnClick = PopupMenuItemsClick;// assign it an event handler end;end;
打开时: var MmItem: TMenuItem; begin MmItem := TMenuItem.Create(Form1.MainMenu1); MmItem.Caption := '新加的'; Form1.MainMenu1.Items[0].Insert(1,MmItem); //假设N3为第2个 end;关闭: procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin Form1.MainMenu1.Items[0].Delete(2); end;———————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 ————————————————————————————————————
var
index: Integer;
NewItem: TMenuItem;
begin
for index := 0 to 3 do
begin
NewItem := TMenuItem.Create(PopupMenu1); // create the new item
PopupMenu1.Items.Add(NewItem);// add it to the Popupmenu
NewItem.Caption := 'Menu Item ' + IntToStr(index);
NewItem.Tag := index;
NewItem.OnClick = PopupMenuItemsClick;// assign it an event handler
end;end;
var
MmItem: TMenuItem;
begin
MmItem := TMenuItem.Create(Form1.MainMenu1);
MmItem.Caption := '新加的';
Form1.MainMenu1.Items[0].Insert(1,MmItem); //假设N3为第2个
end;关闭:
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.MainMenu1.Items[0].Delete(2);
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
Formname.mainmenu1.items.add(TMenuitem);
Formname.mainmenu1.items.caption;卸载时可以用:
formname.mainmenu1.items.itemsname.destroy;具体操作自己去试;