我正在编写一个outlook外接程序,它为outlook添加了一个菜单。,虽然我将委托设置为菜单的一个操作,但似乎在调用委托(单击菜单项)之后,它就被删除了。下次用户单击时,它将无法到达我的委托。代码示例:
menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(
Office.MsoControlType.msoControlButton, missing, missing, missing, true);
menuCommand.Caption = "&Generate weekly...";
menuCommand.Tag = "Generate";
menuCommand.FaceId = 65;
menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand_Generate_Click);
menuCommand = (Office.CommandBarButton)cmdBarControl.Controls.Add(
Office.MsoControlType.msoControlButton, missing, missing, missing, true);
menuCommand.Caption = "&About";
menuCommand.Tag = "About";
menuCommand.FaceId = 65;
menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand_About_Click);
menuCommand.BeginGroup = true;我该怎么做才能让菜单每次都触发动作?
发布于 2011-05-11 12:42:28
菜单项是局部变量吗?,因为垃圾收集器一旦超出范围,就会清除掉。
尝试将变量保存在全局对象中。
https://stackoverflow.com/questions/5964050
复制相似问题