• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Visual Studio Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Download
 
 
Support
 
 
Community
 
 
Forums
 
 
 
Visual Studio Developer Center > Visual Studio Forums > Visual Studio Extensibility > Adding controls to toolbox
Ask a questionAsk a question
Search Forums:
  • Search Visual Studio Extensibility Forum Search Visual Studio Extensibility Forum
  • Search All Visual Studio Forums Search All Visual Studio Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerAdding controls to toolbox

  • Friday, October 05, 2007 6:33 PMSomesh Chandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    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

     

    • ReplyReply
    • QuoteQuote
     

Answers

  • Tuesday, October 09, 2007 7:03 PMEd DoreMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

    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,

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 8:13 PMSomesh Chandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

     

    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

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 8:16 PMSomesh Chandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

     

    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

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 8:19 PMEd DoreMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    0

    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,

    • ReplyReply
    • QuoteQuote
     

All Replies

  • Friday, October 05, 2007 7:15 PMAaron MartenMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    Hi Somesh,

     

    Is this a WPF based button or WinForms?

     

    Thanks,

    Aaron

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 2:54 AMFeng ChenMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    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!

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 2:05 PMSomesh Chandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    This is related to Winform and dot net framework 2.0.

     

    Thanks,

    Somesh

     

    • ReplyReply
    • QuoteQuote
     
  • Tuesday, October 09, 2007 2:10 PMSomesh Chandra Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0

    Thanks Feng,

     

    I have mofdifed the question.

     

    Thanks,

    Somesh

     

    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement