user1186860
user1186860

Reputation:

Adding ToolBoxTab and ToolBoxItems in Visual Studio through an Add-In

I have made my own control class by overriding base controls i.e.

[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 do, is to Add these overridden controls in ToolBox window of the visual studio.

To do that, I simply do this.

  1. Add a new Tab in ToolBox Window by right click and "Add Tab"
  2. and then I do "Choose Items" (right click) and point to the dll of my control class.

All the controls that I have overridden i.e. TextBox, Button, Label appears there with the new name and icon. All I have to do is to drag them and use them.

Now, Is there a way, that my controls get loaded automatically? I mean I don't want to do above mentioned two steps.

See this is what I did.

  1. Added an add-in and in its Exec, did this

    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. 'Test Controls' tab was there but no control. When I try to do same with System.Configuration.Install.dll ( found in [root]/Windows/Microsoft.Net/Framework/[dotnetVersion]/) folder).. controls get loaded perfectly..but not when my custom control dll is being pointed.

please help me. I want to add those controls everytime IDE starts up (like telerik controls). am new to this Extensibility Project Type of Visual Studio..

please help....

Upvotes: 6

Views: 860

Answers (2)

Efran Cobisi
Efran Cobisi

Reputation: 6464

Since you are going to deploy your control using a setup installer, I would suggest using the Toolbox Controls Installer, which come with the Visual Studio SDK and can be easily integrated into Wix; this way, you could author your Wix setup project, include your assembly and just reference the aforementioned custom action for toolbox registration.

Upvotes: 0

Arci
Arci

Reputation: 588

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

Upvotes: 1

Related Questions