Adding Custom Tab into Toolbox of VS 2003 or 2005

Souce Code
/// Adding Custom ToolTab into ToolBox of Visual Studio 2003 or 2005
/// </summary>
/// <param name=”sAssemblyPath”>Path of Assembly</param>
/// <param name=”sTabName”>Tab Name</param>
/// <param name=”sControlName”>Control Name</param>
/// <param name=”isWhidbey”>Check whether VS2k3 or VS2k5</param>
/// <returns></returns>
public static bool RegisterControl(string sAssemblyPath,string sTabName,
string sControlName,bool isWhidbey) {
try {
EnvDTE.DTE dte;

dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject(“VisualStudio.DTE.8.0”);
dte = (EnvDTE.DTE)System.Runtime.InteropServices.Marshal.GetActiveObject(“VisualStudio.DTE.7.1”);

ToolBox objToolBox;
ToolBoxTabs colTbxTabs;
ToolBoxTab objTab;
ToolBoxItem objTbxItem ;
// Create an object reference to the IDE’s ToolBox object.
objToolBox = (EnvDTE.ToolBox)dte.Windows.Item(Constants.vsWindowKindToolbox).Object;
colTbxTabs = objToolBox.ToolBoxTabs;

* In some cases if the propeties window is hidded or closed, this line will activate the properties window.And the second line you have cited will add the controls to the active tab.In some case if the tab is not made active, the controls will be added either to the active tab or to the general tab section.It might work in your case, but does not in certain cases, better to do it sequentially giving no room for errors.

//ToolBoxWnd.Visible = true;

for(int i=1; i < colTbxTabs.Count ; i++) {
if(colTbxTabs.Item(i).Name.ToString().Trim() == sTabName) {
objTab = colTbxTabs.Item(i);
foreach(ToolBoxItem tbxi in objTab.ToolBoxItems) {
//Print ToolboxItem.
//Delete if it is already exist.
// Add a new tab to the ToolBox.
objTab = colTbxTabs.Add(sTabName);

///Adding the .Net control to the Toolbox
sAssemblyPath , vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);
//Must be null if the control is many child controls. (VS2003)
sAssemblyPath , vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);

return true;
catch(Exception ex) {
Console.WriteLine(“RegisterControl(string) : ” + ex.Message) ;
return false;


UsageRegisterControl(txtAsmPath.Text, txtTabName.Text,txtControlName.Name,chkIsWhidbey.Checked);


  1. The Custom ToolBar will be created in the first instance of VS IDE. (It’s better if you open only one VS IDE.)
  2. Form Designer should be shown. (If TextEditor is shown then, this code wont’ execute properly because VS IDE automatically prevent the usage of Toolbox if Text Editor is shown.)

Download SouceCode :

Let me know if you have any problem with this soucecode. Thanks.

5 Replies to “Adding Custom Tab into Toolbox of VS 2003 or 2005”

  1. Hi everyone,

    I am facing the same problem with WPF controls.
    I created a very simple WPF custom control by creating a Custom Control Library (WPF) project in the Visual Studio 2005. This control is just a wrapper of the button control. I compiled it successfully.
    Then, I created a simple WPF Windows Application project in the Visual Studio 2005. Next, I tried to add my newly created WPF custom control into a tab of the toolbox of the newly created WPF Windows Application project through the “Choose Items …”. After browsing and selecting the appropriate DLL of the newly created WPF custom control, I got the following message:
    “There are no components in ” that can be placed in the toolbox”
    I also tried to add my WPF custom control in the same tab programmatically like others in using the ToolBox.Items.Add method. This famous method has returned a null object instead of the newly created toolbox item object without throwing any exception. Therefore, my custom control did not appear in that tab of the toolbox.

    I was thinking that because all the WPF projects have to work with the Visual Studio 2005 Extensions for .Net Framework 3.0 including WPF, WCF. However, the integration beetween those extensions and the Visual Studio 2005 was’nt working properly as expected.

    Does anyone have some idea about that to help me out.

    Thanks a lot,


Leave a Reply