Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / April 2004

Tip: Looking for answers? Try searching our database.

ToolboxItems.Add does nothing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hugo Vale - 01 Apr 2004 03:41 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.