Adding controls to toolbox<p align=left><span style="font-size:10pt;font-family:Arial">Hi,</span></p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p align=left><span style="font-size:10pt;font-family:Arial">I am working on vb.net (framework 2.0). Based on some rule my AddIn is supposed to create a new tooltab in toolbox. After creating a tool tab, customized .net controls are required to be added in to the tooltab so that when I open the toolbox (from view-&gt;toolbox menu option) then I can see the newly added tooltaba and controls within it.</span></p> <p align=left><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:10pt;font-family:Arial">I have written following code in my AddIn. This is supposed to create a toolbox tab and add a user created .net button control. It only seems to be adding toolbox tab but control is not added to the tool box. Any idea why ?</span></p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTlBox As ToolBox</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTbxTabs As ToolBoxTabs</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTbxTab As ToolBoxTab</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">' Create an object reference to the IDE's ToolBox object and its tabs.</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTlBox = mDTE.Windows.Item(Constants.vsWindowKindToolbox).Object</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTabs = pTlBox.ToolBoxTabs</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">mDTE.Windows.Item(Constants.vsWindowKindToolbox).Visible = True</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">mDTE.Windows.Item(Constants.vsWindowKindToolbox).Activate()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">' Add a new tab to the Toolbox </span><span style="font-size:10pt;color:blue;font-family:Arial"></span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab = pTbxTabs.Add(&quot;My Tools&quot;)</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.Activate()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.ToolBoxItems.Item(1).Select()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.ToolBoxItems.Add(&quot;My Button&quot;, &quot;C:\MyButton.dll&quot;, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9pt;color:blue"><font face="Times New Roman"></font></span> </p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:10pt;font-family:Arial">Thanks,</span></p> <p><span style="font-size:10pt;font-family:Arial">Somesh</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9pt"><font face="Times New Roman"></font></span> </p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Za25886e4-ffc8-46be-af3d-19b1bfde8c3dhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a25886e4-ffc8-46be-af3d-19b1bfde8c3dhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a25886e4-ffc8-46be-af3d-19b1bfde8c3dSomesh Chandrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somesh%20ChandraAdding controls to toolbox<p align=left><span style="font-size:10pt;font-family:Arial">Hi,</span></p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p align=left><span style="font-size:10pt;font-family:Arial">I am working on vb.net (framework 2.0). Based on some rule my AddIn is supposed to create a new tooltab in toolbox. After creating a tool tab, customized .net controls are required to be added in to the tooltab so that when I open the toolbox (from view-&gt;toolbox menu option) then I can see the newly added tooltaba and controls within it.</span></p> <p align=left><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:10pt;font-family:Arial">I have written following code in my AddIn. This is supposed to create a toolbox tab and add a user created .net button control. It only seems to be adding toolbox tab but control is not added to the tool box. Any idea why ?</span></p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTlBox As ToolBox</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTbxTabs As ToolBoxTabs</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">Dim pTbxTab As ToolBoxTab</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">' Create an object reference to the IDE's ToolBox object and its tabs.</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTlBox = mDTE.Windows.Item(Constants.vsWindowKindToolbox).Object</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTabs = pTlBox.ToolBoxTabs</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">mDTE.Windows.Item(Constants.vsWindowKindToolbox).Visible = True</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">mDTE.Windows.Item(Constants.vsWindowKindToolbox).Activate()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">' Add a new tab to the Toolbox </span><span style="font-size:10pt;color:blue;font-family:Arial"></span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab = pTbxTabs.Add(&quot;My Tools&quot;)</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.Activate()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial"></span> </p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.ToolBoxItems.Item(1).Select()</span></p> <p><span style="font-size:9pt;color:black;font-family:Arial">pTbxTab.ToolBoxItems.Add(&quot;My Button&quot;, &quot;C:\MyButton.dll&quot;, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9pt;color:blue"><font face="Times New Roman"></font></span> </p> <p><span style="font-size:10pt;font-family:Arial"></span> </p> <p><span style="font-size:10pt;font-family:Arial">Thanks,</span></p> <p><span style="font-size:10pt;font-family:Arial">Somesh</span></p> <p class=MsoNormal style="margin:0in 0in 0pt"><span style="font-size:9pt"><font face="Times New Roman"></font></span> </p>Fri, 05 Oct 2007 18:33:02 Z2007-10-09T20:19:57Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#4911af67-376f-467b-9644-826a69b3c141http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#4911af67-376f-467b-9644-826a69b3c141Aaron Martenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Aaron%20MartenAdding controls to toolbox<p align=left><font face=Arial size=2>Hi Somesh,</font></p> <p align=left> </p> <p align=left>Is this a WPF based button or WinForms? </p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left>Aaron</p>Fri, 05 Oct 2007 19:15:40 Z2007-10-05T19:15:40Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#62f15358-479d-449c-bc4a-d8ddde376dd6http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#62f15358-479d-449c-bc4a-d8ddde376dd6Feng Chenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Feng%20ChenAdding controls to toolbox<font face=Arial size=2> <p class=MsoNormal style="margin:6pt 0in"><font face=Calibri size=3>Hi Somesh,</font></p> <p class=MsoNormal style="margin:6pt 0in"><font face=Calibri size=3>We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.   </font></p> <p class=MsoNormal style="margin:6pt 0in"><font face=Calibri size=3>Thank you!</font></font></p>Tue, 09 Oct 2007 02:54:24 Z2007-10-09T02:54:24Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a8222f66-c7d9-4e02-9bf0-9ab0f23d9a13http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a8222f66-c7d9-4e02-9bf0-9ab0f23d9a13Somesh Chandrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somesh%20ChandraAdding controls to toolbox<p>This is related to Winform and dot net framework 2.0.</p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left>Somesh</p> <p align=left><font face=Arial size=2></font> </p>Tue, 09 Oct 2007 14:05:22 Z2007-10-09T14:05:22Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#8285bea9-3e19-42d3-a409-ce4405873b97http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#8285bea9-3e19-42d3-a409-ce4405873b97Somesh Chandrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somesh%20ChandraAdding controls to toolbox<p>Thanks Feng,</p> <p align=left> </p> <p align=left>I have mofdifed the question. </p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left>Somesh</p> <p align=left><font face=Arial size=2></font> </p>Tue, 09 Oct 2007 14:10:15 Z2007-10-09T14:10:15Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#31809218-4422-4448-86be-1a572e57a247http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#31809218-4422-4448-86be-1a572e57a247Ed Dorehttp://social.msdn.microsoft.com/Profile/en-US/?user=Ed%20DoreAdding controls to toolbox<p align=left>Hi Somesh,</p> <p align=left> </p> <p align=left>Can you confirm that the controls are successfully added when a winform based project is currently active in the IDE? I suspect this is due to a known problem with VS 2003, where adding controls via automation fails unless the winform designer is currently active.</p> <p align=left> </p> <p align=left>Sincerely,</p>Tue, 09 Oct 2007 19:03:34 Z2007-10-09T20:17:15Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a7254555-f410-418c-a2d7-602f95f786a1http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#a7254555-f410-418c-a2d7-602f95f786a1Somesh Chandrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somesh%20ChandraAdding controls to toolbox<p align=left><font face=Arial size=2></font> </p> <p>I have got the solution. There is nothing wrong with the code, which I had written. Only thing which needs to be made sure is that tools can be added if any of the form/usercontrol is open in design mode.</p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left>Somesh</p>Tue, 09 Oct 2007 20:13:21 Z2007-10-09T20:16:56Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#bf0ca259-b8b5-4efd-adf9-1751a7c7a3bbhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#bf0ca259-b8b5-4efd-adf9-1751a7c7a3bbSomesh Chandrahttp://social.msdn.microsoft.com/Profile/en-US/?user=Somesh%20ChandraAdding controls to toolbox<p align=left><font face=Arial size=2></font> </p> <p>Hi Ed,</p> <p align=left> </p> <p align=left>After banging my head for long time I came to the same conclusion. This prb I am facing in VS 2005.</p> <p align=left> </p> <p align=left>So Instead of AddIn-Connect, I need to execute this code when any form or user control is opened in design mode.</p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left>Somesh</p>Tue, 09 Oct 2007 20:16:07 Z2007-10-09T20:17:23Zhttp://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#c3211bd6-a5f3-43cc-895c-682af24cf805http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/a25886e4-ffc8-46be-af3d-19b1bfde8c3d#c3211bd6-a5f3-43cc-895c-682af24cf805Ed Dorehttp://social.msdn.microsoft.com/Profile/en-US/?user=Ed%20DoreAdding controls to toolbox<p>Hi Somesh,</p> <p align=left> </p> <p align=left>I thought that might be the case. Another option would be to use the ToolboxControlsInstaller package that ships with the Visual Studio SDK. See <a title="http://msdn2.microsoft.com/en-us/library/bb166244(VS.80).aspx" href="http://msdn2.microsoft.com/en-us/library/bb166244(VS.80).aspx">ToolboxControlsInstaller Sample</a> for details. You would have to redistribute and run the ToolboxControlsInstaller.msi from your own setup, and then ensure that your controls were properly registered with the package (again see the above sample for details).</p> <p align=left> </p> <p align=left>Sincerely,</p>Tue, 09 Oct 2007 20:19:49 Z2007-10-09T20:19:57Z