im placing two commandbar buttons under a commandbarpopup and i have separate click events for both commandbar buttons menuCommand1 and menuCommand2 and click events
are menuCommand1_Click and menuCommand2_Click......but when im clicking menuCommand1 both the events menuCommand1_Click and menuCommand2_Click are fired and same with menuCommand2 click event
private Office.CommandBarButton menuCommand1;
private office.CommandBarButton menuCommand2;
private string menuTag = "A unique tag";
private void AddMenuBar()
{
try
{
Office.CommandBarPopup cmdBarControl = null;
Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;
int controlCount = menubar.Controls.Count;
string menuCaption = "&New Menu";
// Add the menu.
cmdBarControl = (Office.CommandBarPopup)menubar.Controls.Add(
Office.MsoControlType.msoControlPopup, missing, missing, controlCount, true);
if (cmdBarControl != null)
{
cmdBarControl.Caption = menuCaption;
// Add the menu command.
menuCommand1 = (Office.CommandBarButton)cmdBarControl.Controls.Add(
Office.MsoControlType.msoControlButton, missing, missing, missing, true);
menuCommand1.Caption = "&MyInbox";
menuCommand1.Tag = "NewMenuCommand";
menuCommand1.FaceId = 65;
menuCommand1.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand1_Click);
menuCommand2 = (Office.CommandBarButton)cmdBarControl.Controls.Add(
Office.MsoControlType.msoControlButton, missing, missing, missing, true);
menuCommand2.Caption = "&MySchedule";
menuCommand2.Tag = "NewMenuCommand";
menuCommand2.FaceId = 65;
menuCommand2.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
menuCommand2_Click);
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
private void menuCommand1_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
}
private void menuCommand2_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
}