Adding controls to toolbox
Hi,
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->toolbox menu option) then I can see the newly added tooltaba and controls within it.
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 ?
Dim pTlBox As ToolBox
Dim pTbxTabs As ToolBoxTabs
Dim pTbxTab As ToolBoxTab
' Create an object reference to the IDE's ToolBox object and its tabs.
pTlBox = mDTE.Windows.Item(Constants.vsWindowKindToolbox).Object
pTbxTabs = pTlBox.ToolBoxTabs
mDTE.Windows.Item(Constants.vsWindowKindToolbox).Visible = True
mDTE.Windows.Item(Constants.vsWindowKindToolbox).Activate()
' Add a new tab to the Toolbox
pTbxTab = pTbxTabs.Add("My Tools")
pTbxTab.Activate()
pTbxTab.ToolBoxItems.Item(1).Select()
pTbxTab.ToolBoxItems.Add("My Button", "C:\MyButton.dll", vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent)
Thanks,
Somesh
Ответы
Hi Somesh,
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.
Sincerely,
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.
Thanks,
Somesh
Hi Ed,
After banging my head for long time I came to the same conclusion. This prb I am facing in VS 2005.
So Instead of AddIn-Connect, I need to execute this code when any form or user control is opened in design mode.
Thanks,
Somesh
Hi Somesh,
I thought that might be the case. Another option would be to use the ToolboxControlsInstaller package that ships with the Visual Studio SDK. See ToolboxControlsInstaller Sample 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).
Sincerely,
Все ответы
Hi Somesh,
Is this a WPF based button or WinForms?
Thanks,
Aaron
Hi Somesh,
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.
Thank you!
This is related to Winform and dot net framework 2.0.
Thanks,
Somesh
Thanks Feng,
I have mofdifed the question.
Thanks,
Somesh
Hi Somesh,
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.
Sincerely,
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.
Thanks,
Somesh
Hi Ed,
After banging my head for long time I came to the same conclusion. This prb I am facing in VS 2005.
So Instead of AddIn-Connect, I need to execute this code when any form or user control is opened in design mode.
Thanks,
Somesh
Hi Somesh,
I thought that might be the case. Another option would be to use the ToolboxControlsInstaller package that ships with the Visual Studio SDK. See ToolboxControlsInstaller Sample 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).
Sincerely,

