Hello, I'm trying to add a control to the toolbox using a windows forms
application.
All goes well, and no error found, but it does not appear after the
application finishes (even after i restart Visual Studio.NET).
Thanks in advance
Here is the code:
Dim DevEnv As DTE = New DTEClass()
'Get the list of toolbox tabs
Dim win As Window =
DevEnv.Windows.Item(Constants.vsWindowKindToolbox)
Dim tb As ToolBox = DirectCast(win.Object, ToolBox)
Dim tbt As ToolBoxTabs = tb.ToolBoxTabs
Dim MyToolboxTab As ToolBoxTab
Dim tbtTemp As ToolBoxTab
For Each tbtTemp In tbt
If tbtTemp.Name = "MyControls" Then
MyToolboxTab = tbtTemp
End If
Next tbtTemp
'Adds the "MyControls" tab
If MyToolboxTab Is Nothing Then
MyToolboxTab = tbt.Add("MyControls")
End If
'Make sure the properties window is visible. This gets around a
VS.Net bug when installing toolbox icons
DevEnv.ExecuteCommand("View.PropertiesWindow", String.Empty)
MyToolboxTab.Activate()
MyToolboxTab.ToolBoxItems.Item(1).Select()
'Add controls to the "My Controls" tab
MyToolboxTab.ToolBoxItems.Add("NewButton",
"E:\\Controls\\NewButton\\bin\\NewButton.dll",
vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent).Name)
'I Checked here for MyToolboxTab.ToolBoxItems.Count, and the item is
there.
DevEnv.Quit()
DevEnv = Nothing
Hugo Vale - 02 Apr 2004 18:27 GMT
Hi there,
i finally figured out, i just had to replace this line:
Dim DevEnv As DTE = New DTEClass()
be this one:
Dim t As System.Type =
System.Type.GetTypeFromProgID("VisualStudio.DTE.7")
Dim obj As Object = System.Activator.CreateInstance(t, True)
Dim DevEnv As EnvDTE.DTE = CType(obj, EnvDTE.DTE)
> Hello, I'm trying to add a control to the toolbox using a windows forms
> application.
[quoted text clipped - 37 lines]
> DevEnv.Quit()
> DevEnv = Nothing