Click here to Skip to main content
12,702,933 members (32,752 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

A Visual Studio 2010 style ToolBox control

, 26 Nov 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
VS 2010 style toolbox written in C#


This article aims to show the use of ToolBox control which can be useful for projects like IDE development and other design surface projects.  


The design cue has been borrowed from Visual Studio 2010 and have made all possible efforts to keep it simple and usable.  

Using the code  

Download the attached assembly and add a reference in your project to pplStuff.Controls.ToolBox.dll.

Create an instance of the ToolBox 

private void Form1_Load(object sender, EventArgs e)
    ToolBox toolBox = new ToolBox();

Add Groups

You may  create individual groups and add it to the toolbox 

ToolGroup grpCommon = new ToolGroup();
grpCommon.Caption = "Common Control";
grpCommon.Collapsed = false;

Or create them using constructor

toolBox.ToolGroups.Add(new ToolGroup("Common Control", false)); 

Add Items to Groups

toolBox.ToolItems.Add(new ToolItem(toolBox.ToolGroups[0], "Pointer", Image.FromFile(@"C:\Images\Pointer.jpg"), new object()));

The first parameter of the ToolItem constructor takes a ToolGroup object which must be already added to the control. Second parameter defines the text displayed on the item. Next is the image to be used when creating the toolitem.

The last parameter is an user defined object which can be accessed during runtime. This has been added to cater to requirements when associating an object to an item becomes necessary.  


The toolbox provides one event for Selection Change of items and provides access to the currently selected ToolItem.

toolBox.SelectionChanged += new EventHandler(toolBox1_SelectionChanged);
void toolBox_SelectionChanged(object sender, EventArgs e)
    ToolItem item = sender as ToolItem;

Clearing item selection

ClearItemSections() method can be used to clear current selection of item in the toolbox.


Removing Groups/Items from the ToolBox    

Groups or items can be removed from the toolbox by simply removing them from the collections

To remove the first group  


 To remove the 5th item from the toolbox (Item indexes are independent of the group they are in)


Drag & Drop 

The toolbox supports DragDrop operation and can be implemented as follows

  • I have created a panel and placed a label inside the panel to show the text of item being dropped. 
private void panel1_DragEnter(object sender, DragEventArgs e)
    if (e.AllowedEffect == DragDropEffects.Copy)
       e.Effect = DragDropEffects.Copy;
private void panel1_DragDrop(object sender, DragEventArgs e)
    ToolItem item = e.Data.GetData(typeof(ToolItem)) as ToolItem;
    lblDemo.Text = item.Text;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionControl After Drop Pin
Member 1105648317-May-16 3:11
memberMember 1105648317-May-16 3:11 
QuestionpplStuff.Controls.ToolBox.dll Pin
abdulaziz M.9-Apr-14 23:13
memberabdulaziz M.9-Apr-14 23:13 
QuestionMy vote of 2 Pin
pitoloko31-Dec-13 23:05
memberpitoloko31-Dec-13 23:05 
SuggestionMissing core functionality - doubleclick on ToolItem Pin
devslo20-Nov-13 0:07
memberdevslo20-Nov-13 0:07 
AnswerRe: Missing core functionality - doubleclick on ToolItem Pin
devslo20-Nov-13 22:02
memberdevslo20-Nov-13 22:02 
QuestionSource for control missing Pin
Waseem Anis8-May-13 23:27
memberWaseem Anis8-May-13 23:27 
GeneralMy vote of 5 Pin
Flash2009-MX21-Mar-13 11:36
memberFlash2009-MX21-Mar-13 11:36 
QuestionFull Size image Pin
LordD4rkHelmet22-Jan-13 19:42
memberLordD4rkHelmet22-Jan-13 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 26 Nov 2012
Article Copyright 2012 by nilotpalbarpujari
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid