2012-08-17 29 views

回答

0

我用這樣的事情如果它的任何幫助你:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) 
{ 
    _application = (DTE2)application; 
    if (connectMode == ext_ConnectMode.ext_cm_Startup) 
    { 
    // Other command bars are: "Code Window", "ASPX Code Context" 
     var commandBar = _application.CommandBars["ASPX Context"]; 

     CommandBarButton test = 
       commandBar.Controls.Add(MsoControlType.msoControlButton, 
       System.Reflection.Missing.Value, 
       System.Reflection.Missing.Value, 
       System.Reflection.Missing.Value, true) as CommandBarButton; 

      // Set the caption of the submenuitem 
      test.Caption = "Edit"; 
      test.Enabled = true; 
      test.Visible = true; 
      test.Click += new _CommandBarButtonEvents_ClickEventHandler(MyEventHandler); 
    } 
} 
相關問題