Adding controls to Visual Studio Toolbox

Tuesday, February 28, 2006 by ASP.NET AJAX Team | Comments 10

The Problem

As Rumen said, adding controls to Visual Studio toolbox can be a tedious procedure. That's why r.a.d.controls are automatically added in the toolbox during installation. This makes it easier for the developer to start using them. However there is a catch - no control is added in Visual Studio 2005... Our toolbox adding code runs without an error but ... nothing happens. Several months ago I found the following forum thread which basically said that the code used to add toolbox items in Visual Studio 2003 will simply not work in Visual Studio 2005. And it is 100% right! We decided to abandon this task and continue with our lives.

In more recent times I came upon the following blog post which looked promising. I downloaded the sample code and ran a couple of tests. And it worked!!! No, it worked only when Visual Studio 2005 had been started beforehand... I instantly imagined the following dialog box "Dear customer, please start your Visual Studio 2005, so we can install our components in your toolbox. Would you?". Yeah, a very bad idea. Once again adding to Visual Studio 2005 was abandoned for better times.

The solution

A few days ago Stoyan brought the following blog post to my attention. The code described there is quite similar to the one we used to add controls to Visual Studio 2003 toolbox but actually works!!! Yes there are ugly COM-ish artefacts:
[ComImport(), Guid("00000016-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType
.InterfaceIsIUnknown)]

[
DllImport("ole32.dll"
)]
private static extern int CoRegisterMessageFilter(
IOleMessageFilter newFilter, out IOleMessageFilter
oldFilter);
 

It works and I don't care.

So to summarize:

  • To add toolbox items in Visual Studio 2003 you can use the code frome here
  • To add toolbox items in Visual Studio 2005 you should use the code from here

 

10 Comments

  • my virus 01 Mar 2006
    >> "Dear customer, please start your Visual Studio
    >>2005, so we can install our components in your
    >> toolbox. Would you?".
    This sounds like the dumbest virus I've seen:
    "Dear Victim,
    Please, send this text to all contacts in your address book and then delete your hard disk.

    Sincerely yours, the virus."
  • Atanas Korchev 02 Mar 2006
    As a matter of fact this is a very popular joke here:) This was the message sent by the first Albanian virus!!!
  • Mark 23 Mar 2006
    I have tried every variation of adding controls I can come across. At the point where it wants to add:
    myTab.ToolBoxItems.Add( "FileMan1", ctrlPath, vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent);

    The returned ToolBoxItem is ALWAYS undefined and I can't find a reason why!! I'm using VS2003 so I am referencing VisualStudio.DTE.7.1. Everything looks right up to the Add.
  • Kosta 08 May 2007
    Nice...
  • Nikolaos 09 May 2007
    interesting
  • Nikolaos 09 May 2007
    interesting
  • Theodore 13 May 2007
    Interesting...
  • Theodore 13 May 2007
    Interesting...
  • Kristion 13 May 2007
    Cool...
  • pravallika 07 Dec 2010
    this is pravalllika.i need some information regarding telerik control.is there any website for that d ineed some informatiom how telerik ccontrol software available d how it should be installed

Add comment

  1. Formatting options
       
     
     
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)