1
我正在開發一個Microsoft Outlook加載項,在Add-In標籤名稱中添加了一個按鈕名稱OPENISMS
。我可以看到按鈕,但點擊事件沒有被解僱。我不知道爲什麼它會以這種方式行事。請在下面找到添加按鈕並將事件附加到它的代碼。任何幫助將不勝感激。Outlook事件不會被點擊自定義按鈕
private void AddButtonToNewDropdown()
{
Office.CommandBar commandBar = this.Application.ActiveExplorer().CommandBars["Standard"];
Office.CommandBarControl ctl = commandBar.Controls["&New"];
if (ctl is Office.CommandBarPopup)
{
Office.CommandBarButton commandBarButton;
Office.CommandBarPopup newpopup = (Office.CommandBarPopup)ctl;
commandBarButton = (Office.CommandBarButton)newpopup.Controls.Add(1, missing, missing, missing, true);
commandBarButton.Caption = "OpenISMS";
commandBarButton.Tag = "OpenISMS";
commandBarButton.FaceId = 6000;
//commandBarButton.Enabled = false;
commandBarButton.OnAction = "OpenISMSThruMail.ThisAddIn.ContextMenuItemClicked";
commandBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ContextMenuItemClicked);
}
}
private void ContextMenuItemClicked(CommandBarButton Ctrl, ref bool CancelDefault)
{
if (currentExplorer.Selection.Count > 0)
{
object selObject = currentExplorer.Selection[1];
if (selObject is MailItem)
{
// do your stuff with the selected message here
MailItem mail = selObject as MailItem;
MessageBox.Show("Message Subject: " + mail.Subject);
}
}
}
我打電話從ThisAddIn_Startup
事件AddButtonToNewDropdown()
方法。
太好了 - 很高興它幫助你。請將此標記爲已接受的答案,以便其他人可以獲益。只需點擊投票箭頭左側的勾號(*複選標記*)即可。 – SliverNinja