Adding ToolBoxTab and ToolBoxItems to Visual Studio Using an Add-In

I created my own control class by overriding the main controls that is.

[ToolboxData("<{0}:TextBox runat=server></{0}:TextBox>")] public class MyTextBox:System.Web.UI.WebControls.TextBox { public string myProperty {get;set;} } 

Now for ease of use, what I am doing is adding these overridden controls to the Visual Studio ToolBox window.

For this, I just do it.

  • Add a new tab to the ToolBox by right-clicking and "Add Tab"
  • and then I do "Select Items" (right-click) and point to the DLL of my control class.

All the controls that I redefined, that is, TextBox, Button, Label appear there with a new name and icon. All I have to do is drag them and use them.

Now, is there a way for my controls to load automatically? I mean, I do not want to take the above two steps.

Here is what I did.

  • Added add-in and in her Exec, did it

     public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if(commandName == "testAddin.Connect.testAddin") { handled = true; ToolBox tlBox = _applicationObject.ToolWindows.ToolBox; ToolBoxTab tlBoxTab = null; tlBoxTab = tlBox.ToolBoxTabs.Add("Test Controls"); tlBoxTab.Activate(); tlBoxTab.ToolBoxItems.Add("TestControls", @"C:\testLib.dll", vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent); ///// } 

... but nothing happened. The "Test Controls" tab was there, but without control. When I try to do the same with System.Configuration.Install.dll (located in the [root] /Windows/Microsoft.Net/Framework/ [dotnetVersion] / folder)) .. the controls load fine .. but not when indicated my custom dll.

Please help me. I want to add these controls every time the IDE is launched (e.g. telerik controls). new to this extensibility project. Type Visual Studio ..

please, help....

+6
source share
2 answers

Try Visual Studio Toolbox Manager . I have my own updated version for VS2010 (DTE for VS2010 is "VisualStudio.DTE.10.0").

+1
source

Since you are planning to deploy your control using the installation installer, I would suggest using the Toolbox Controls Installer that comes with the Visual Studio SDK and can be easily integrated into Wix; that way, you could create your Wix installation project, enable your build, and just refer to the above custom actions to register the toolbar.

0
source

Source: https://habr.com/ru/post/918727/


All Articles