提出问题提出问题
 

已答复Adding controls to toolbox

  • 2007年10月5日 18:33Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    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

     

答案

  • 2007年10月9日 19:03Ed DoreMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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,

  • 2007年10月9日 20:13Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

     

    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

  • 2007年10月9日 20:16Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

     

    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

  • 2007年10月9日 20:19Ed DoreMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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,

全部回复

  • 2007年10月5日 19:15Aaron MartenMSFT, 所有者:用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    Hi Somesh,

     

    Is this a WPF based button or WinForms?

     

    Thanks,

    Aaron

  • 2007年10月9日 2:54Feng Chen版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    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!

  • 2007年10月9日 14:05Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    This is related to Winform and dot net framework 2.0.

     

    Thanks,

    Somesh

     

  • 2007年10月9日 14:10Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    Thanks Feng,

     

    I have mofdifed the question.

     

    Thanks,

    Somesh

     

  • 2007年10月9日 19:03Ed DoreMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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,

  • 2007年10月9日 20:13Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

     

    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

  • 2007年10月9日 20:16Somesh Chandra 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

     

    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

  • 2007年10月9日 20:19Ed DoreMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    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,