auto generate toolbox tab

  • Thread starter Thread starter R.A.F.
  • Start date Start date
R

R.A.F.

Hi,

I would like to know how can i do to make my custom controls
automatically installed on ToolBox palette and in the right tab.

for example, if my tab does not exist, it should create it and install
the custom control there.

If my control already exists, it should replace it based on control
version number.

thanks a lot for any help.

RAF
 
Now I'm able to create a tab, but i'm not able to install the component..
here is my code :

// Create a EnvDTE object.
System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
// visual studio 2005

object obj = System.Activator.CreateInstance(t, true);
EnvDTE.DTE env = (EnvDTE.DTE)obj;

// Find the ToolBox Window and ToolBox Tabs collection
Window win = env.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
ToolBox tb = (ToolBox)win.Object;
ToolBoxTabs tbts = tb.ToolBoxTabs;

// check if the tabs we will create, already exist
int i = 1;
bool bFound = false;
while ( (i < tbts.Count) && !bFound)
{
if (tbts.Item(i).Name == "RogTech")
{
// the tab already exists, so we will update it with new control version
bFound = true;
}

i++;
}
if (!bFound)
{
// the tab does not exist, so we will create it.
// Insert a new Tab in the tab collection.
ToolBoxTab tbt = tbts.Add("RogTech");
tbt.Activate();

// Insert the new Component.
EnvDTE.ToolBoxItem tbi = tbt.ToolBoxItems.Add("XGrid",
@"XTGrid.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);

// release environment
env.Solution.Close(false);
Marshal.ReleaseComObject(env);

}
 
Back
Top