Adding controls to Visual Studio Toolbox

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

 

About the author

Stefan Rahnev

Stefan Rahnev

is the Unit Manager of the ASP.NET Telerik Division. He has been working for the company since 2005, when he started out as a regular support officer. His next steps at Telerik took him through the positions of Technical Support Director and co-team leader in one of the ASP.NET AJAX teams. Stefan’s main interests are web development, agile processes planning and management, client services and psychology.

10 Comments

my virus
>> "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
As a matter of fact this is a very popular joke here:) This was the message sent by the first Albanian virus!!!
Mark
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
Nice...
pravallika
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

Comments

  1.    
      
      
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)
Read more articles by ASP.NET AJAX Team - or - read latest articles in Developer Tools