Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 1.50 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Visual Studio 2010 Add-in Button click doesnt fire
  2. CommandBar menuBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"];
  3.                     CommandBarPopup toolsPopup = (CommandBarPopup)menuBar.Controls["Tools"];
  4.  
  5. _popupMenu = (CommandBarPopup)toolsPopup.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true);
  6. popupMenu.Caption = "My Addin";
  7.  
  8. _btnRefreshProdData = (CommandBarButton)_popupMenu.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
  9. _btnRefreshProdData.Style = MsoButtonStyle.msoButtonIconAndCaption;
  10. _btnRefreshProdData.Caption = "Refresh Product Data";
  11. _btnRefreshProdData.Click += new _CommandBarButtonEvents_ClickEventHandler(OnRefreshProdData);
  12. _btnRefreshProdData.Enabled = true;
  13.  
  14. _btnRefreshEngCodes = (CommandBarButton)_popupMenu.Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true);
  15. _btnRefreshEngCodes.Style = MsoButtonStyle.msoButtonIconAndCaption;
  16. _btnRefreshEngCodes.Caption = "Refresh Engine Codes";
  17. _btnRefreshEngCodes.Click += new _CommandBarButtonEvents_ClickEventHandler(OnRefreshEngineCodes);
  18. _btnRefreshEngCodes.Enabled = true;
  19.        
  20. private void OnRefreshEngineCodes(CommandBarButton Ctrl, ref bool CancelDefault)
  21. {
  22.     MessageBox.Show("I can see this message");
  23. }
  24.  
  25. private void OnRefreshProdData(CommandBarButton Ctrl, ref bool CancelDefault)
  26. {
  27.     ExternalNamespace.Test test = new ExternalNamespace.Test();
  28.     test.Test();
  29.     MessageBox.Show("I can't see this message");
  30. }