
Customize the Toolbox #27
Chapter 4, Customizing Visual Studio
|
111
HACK
If you are building your own control, it’s easy to add a cus-
tom toolbox icon: create a 16 × 16 bitmap and add it to your
project. You will need to ensure that the name of the bitmap
is the same as the name of the control and the bitmap is set
to be an embedded resource.
Code Snippets and the Toolbox
The normal use of the toolbox includes adding and removing tabs and con-
trols, but you can also use the toolbox to store code snippets. Whether you
want to store a method call to get a connection string, a commonly used
piece of JavaScript, or an architecture-specific piece of code, the toolbox is a
great place to save those pieces of code that you constantly find yourself typ-
ing.
Before adding any code snippets to the toolbox, it is a good idea to add a
separate tab to the toolbox for your code snippets: right-click on the tool-
box and select Add Tab, then enter a name for the tab (such as
Code
Snippets
) in the text box that appears at the bottom of the toolbox.
Storing a piece of code in the toolbox is simple: select the code from the
document window and drag it over to the toolbox. After dropping the code
on the toolbox, you will see a snippet like the one shown in Figure 4-15.
This code snippet can now be dragged and dropped from the toolbox to the
document window, and the included code will be pasted into the docu-
ment. You ...