把控件加到toolbar上
加envdte.dll到你的project string progpath=Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); try{ Type latestDTE = Type.GetTypeFromProgID("VisualStudio.DTE"); EnvDTE.DTE dte = Activator.CreateInstance(latestDTE) as EnvDTE.DTE; if(dte!=null){ Window win=dte.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox); ToolBox tb=(ToolBox)win.Object; ToolBoxTabs tbts=tb.ToolBoxTabs; ToolBoxTab tbt=null; ToolBoxTab mytab=null; foreach(ToolBoxTab t in tbts){ if(t.Name=="Web Forms") tbt=t; if(t.Name=="magic") mytab=t; } if(tbt!=null){ foreach(ToolBoxItem ti in tbt.ToolBoxItems){ if(ti.Name=="naBar") ti.Delete(); } tbt.Activate(); dte.ExecuteCommand("View.PropertiesWindow",String.Empty); tbt.ToolBoxItems.Add("AspNetPager", ApplivationUserPatth+@"magic.dll",vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent); } if(mytab==null){ mytab=tbts.Add("magic"); } else{ foreach(ToolBoxItem ti in mytab.ToolBoxItems){ if(ti.Name=="RCell") ti.Delete(); } } mytab.Activate(); dte.ExecuteCommand("View.PropertiesWindow",String.Empty); mytab.ToolBoxItems.Add("AspNetPager",ApplivationUserPatth+@"magic.dll",vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent); } else System.Windows.Forms.MessageBox.Show("Add component to toolbar oprttion doesn't sucess!"); }catch(Exception ex){ System.Windows.Forms.MessageBox.Show("Add component to toolbar oprttion doesn't sucess!Add it by your hand!"+Environment.NewLine+ex.Message); }

|