add control onto ToolBox palette
am 11.10.2007 07:41:09 von Scott LindnerHi,
I'm still struggling with my issue about how programmatically add a
custom control on Toolbox palette.
it creates well my TAB with my custom name, but it does not add my
custom control.
where could the problem be ?
here is the 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);
}
thanks a lot,
RAF