Click here to Skip to main content
13,800,880 members
Click here to Skip to main content
Add your own
alternative version


162 bookmarked
Posted 24 May 2006

IPToolbox: A VS2005-like Toolbox

, 25 May 2007
Rate this:
Please Sign up or sign in to vote.
A Visual Studio 2005-like ToolBox control which supports almost all features of the original: drag'n'drop, renaming, hiding tabs, items, and disabling items

Sample Image - Common View

Sample Image - Multilevel Tabs

Sample Image - Renaming Item


While working on my own Forms designer, I used a Toolbox from another article by Giordio Santini. However, when I saw the Toolbox in VS2005 and, after unsuccessful trials to find something like it on the Internet, I decided to make my own. That is what I've done. This control is derived directly from System.Windows.Forms.Control without using any other controls or components except ScrollBar. All drawing is made by myself and it is divided into three parts: the drawing of the whole toolbox, the single tab and the item.

Using the code

This component is fully supported by the VS designer. Just add a reference to the compiled DLL and add the toolbox or HostToolbox to your form. Alternatively, create it using the following code:

private IP.Components.Toolbox toolbox1;
toolbox1 = new IP.Components.Toolbox();

You have a wide variety of settings for customizing the toolbox appearance, starting from the height of the tabs and the items, to the colors which are used for the selected item or tab, the hovered item, selection borders, and others. For more details, see the Toolbox Appearance category in the toolbox properties. Starting from version 1.2 of this component, both the Toolbox control and the Tab object implement the ITab interface. It provides support for multilevel Tabs and non-categorized Items because interface defines three primary properties:

  • Categories - a collection of Tabs; you could make changes to this collection at design-time and they would be displayed immediately on the control
  • Items - a collection of items in a category or non-categorized items of the toolbox
  • Owner - an owner of the object; it is always Null for Toolbox control

Sample Image - Tab Menu

Sample Image - Item Menu

In the Toolbox category, you can find more properties:

  • CreateGeneralCategory - used to mimic the VS2005 toolbox; it creates an empty tab at run-time with the property AllowDelete set to false, by default
  • ItemMenu - contains the ContextMenuStrip menu object, which is shown when the user right-clicks on any enabled Item; I've added the default menu, but you can change it and set your own
  • TabMenu - like an ItemMenu, contains a menu which would be displayed when the user right-clicks on a Tab; I've also added a default menu

Each Tab object has its own properties, which include:

  • Text - caption of the tab
  • Opened, Visible - properties say what they mean
  • AllowDelete - if this property is set to true, then the tab cannot be deleted from the toolbox; it can be deleted only programmatically by setting AllowDelete = false
  • Selected - at run-time, you can determine if the tab is currently selected.

Also, Tab has a readonly field: PointerItem. This is an Item that is always added to a Tab at first place and does not get added to the Items collection. Thus, it cannot be removed. As with Tab, Item objects also have properties: Text, Image, Tooltip, Enabled, Visible, and Selected. I've also added the properties BackColor and ForeColor, but haven't used them. If you want, you can inherit from the Toolbox.Item class, override the OnPaint method and use those properties for drawing before adding your items to the tabs. For programmers, I've added many public and protected methods and events, including:

  • Public Toolbox.Save/Toolbox.SaveXml and Toolbox.Load/Toolbox.LoadXml for serializing/deserializing the state of a toolbox
  • Public Tab.SortItems for sorting items by alphabetical order
  • Public Tab.Select/Item.Select for selecting tabs/items in a program
  • Protected method OnSelectedChanged and public event SelectedChanged for both tabs and items
  • Public Tab.EnsureVisible/Item.EnsureVisible for scrolling to tab/item
  • Protected methods for handling Paint, MouseDown, MouseUp events on tabs and items
  • Protected method Tab.OnToggleTab and public event Tab.Toggle for handling the toggling of a tab

...and others.

Terms and conditions

The IPToolbox control is provided as free software with source code provided. You can freely use it in your applications, commercial or non-commercial. Ivan Popok, the author of the control, owns the copyright of the control and is NOT responsible for any damage to your application caused by using this control, directly or indirectly.


  • 05/24/2006 - v.1.0
  • 10/10/2006 - v.1.1
    • Added missing SelectItem event and SelectedItem property
    • Added the ShowPointer property that enables hiding of the pointer
    • Added the AutoScroll property and the ScrollView method for synchronized scrolling of the Toolbox and other controls
    • Added the TransparentColor property for the Item class
    • Rewrote the HitTest method
    • Now uses the ToolboxService class from .NET instead of my own implementation
    • Added gradient background drawing and support for background image
    • Added comments for all public and protected properties
  • 10/25/2006 - v.1.2
    • Added multilevel tabs (see AllowNestedTabs property)
    • Added placing items directly on the Toolbox (see AllowToolboxItems property)
    • Added OnClick and OnDoubleClick protected methods for Tab and Item objects
    • Added ColorStyle.None enumeration member (see TabColorStyle property)
    • Fixed drawing of the Item image
    • Fixed showing of TextBox for renaming
  • 03/23/2007 - v.1.2.1
    • Fixed saving the state of CreateGeneralTab property
    • Fixed serialization and deserialization of the nested tabs and toolbox items
    • Fixed adding Tab object to its own collection
    • Added Tag property for Tab and Item classes
    • Some other minor fixes
  • 05/25/2007 - v.1.3
    • Re-engineered serialization/deserialization of Items
    • Applied antialiasing


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Ukraine Ukraine
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionLicense Pin
Member 1305043414-Mar-17 5:19
memberMember 1305043414-Mar-17 5:19 
GeneralGreat work!!!! Pin
rejectkosta27-Apr-10 5:24
memberrejectkosta27-Apr-10 5:24 
Generalcontrols added to the forms Pin
snow_cap17-May-09 3:31
membersnow_cap17-May-09 3:31 
QuestionMenu Pin
LaNono6-Oct-08 5:36
memberLaNono6-Oct-08 5:36 
Questionhow can i export a form which designed with form generator? Pin
mohi_saboohi17-Jul-08 5:10
membermohi_saboohi17-Jul-08 5:10 
GeneralCool... thanks... its very helpfull Pin
aschip7-Jul-08 2:16
memberaschip7-Jul-08 2:16 
QuestionHow to know which control is drawn from the toolbox Pin
Kumara Swamy17-Feb-08 19:06
memberKumara Swamy17-Feb-08 19:06 
QuestionHow can I programatically add component from de IPToolbox to my DesignSurface? Pin
yarlen.vasquez13-Feb-08 11:55
memberyarlen.vasquez13-Feb-08 11:55 
QuestionRightToLeft? Pin
m_jahedbozorgan26-Jan-08 22:36
memberm_jahedbozorgan26-Jan-08 22:36 
GeneralDrag'n'drop a tab to another tab Pin
MagnusO17-Dec-07 3:37
memberMagnusO17-Dec-07 3:37 
QuestionUsage of this toolbox Pin
Vagga Raghavendra13-Aug-07 23:50
memberVagga Raghavendra13-Aug-07 23:50 
Questionkeyboard support ? Pin
[Neno]9-Jul-07 0:07
member[Neno]9-Jul-07 0:07 
GeneralAbsolute Great Pin
zapap24-Jun-07 22:32
memberzapap24-Jun-07 22:32 
GeneralWell done! Pin
Nordin Rahman25-May-07 23:46
memberNordin Rahman25-May-07 23:46 
GeneralRe: Well done! Pin
I@n28-May-07 23:28
memberI@n28-May-07 23:28 
GeneralRe: Well done! Pin
__Andreas__2-Jul-07 21:49
member__Andreas__2-Jul-07 21:49 
GeneralThe Obsolete Serialize functions?? [modified] Pin
[Neno]25-May-07 12:56
member[Neno]25-May-07 12:56 
GeneralRe: The Obsolete Serialize functions?? Pin
I@n28-May-07 23:19
memberI@n28-May-07 23:19 
Hi, Neno

Yes, Obsolete warnings are correct, try to avoid using of those methods in your code.

[Neno] wrote:
And the image files are there now but they look strange.. the background of the image files is not transparant anymore, it's black.
The image files I added are from png files.

That's the problem that I've not included serialization of images by default in previous versions - from the runtime I can't determine what type of the image is associated with the Item, so I've hardcoded to serialize it to BMP format. But bmp is lossy format compared to png, so the backgroud of the image is lost.
To solve the problem, you have to serialize images manually.
Inherit from the Item class, override Image property and add an XmlIgnore attribute for it, then override methods SerializeToXml and DeserializeXml like that:
public override System.Drawing.Image Image
    get { return base.Image; }
    set { base.Image = value; }

protected override System.Xml.XmlElement SerializeToXml(System.Xml.XmlDocument document)
    System.Xml.XmlElement xml = base.SerializeToXml(document);

    using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
        Image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
        xml.SetAttribute("Image", Convert.ToBase64String(stream.ToArray()));

protected override void DeserializeXml(XmlElement element)
    System.Xml.XmlAttribute imageAttribute = element.Attributes["Image"];
    if (imageAttribute != null)
        System.IO.MemoryStream stream = new System.IO.MemoryStream(Convert.FromBase64String(attribute.Value));
        this.Image = System.Drawing.Image.FromStream(stream);

You can omit overriding of Image property and DeserializeXml method, but in that case image would be serialized twice, though only the second would be saved to XML
QuestionHow show in PropertyGrid list of Controls Pin
bsord_25-May-07 4:51
memberbsord_25-May-07 4:51 
GeneralSave the settings to XML, missing image on item Pin
[Neno]23-May-07 8:32
member[Neno]23-May-07 8:32 
AnswerRe: Save the settings to XML, missing image on item Pin
I@n23-May-07 22:56
memberI@n23-May-07 22:56 
GeneralRe: Save the settings to XML, missing image on item [modified] Pin
[Neno]24-May-07 8:18
member[Neno]24-May-07 8:18 
NewsRe: Save the settings to XML, missing image on item Pin
I@n25-May-07 5:07
memberI@n25-May-07 5:07 
GeneralRe: Save the settings to XML, missing image on item Pin
[Neno]25-May-07 7:33
member[Neno]25-May-07 7:33 
GeneralAntiAliased Text Pin
kin3tik8-May-07 11:20
memberkin3tik8-May-07 11:20 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181215.1 | Last Updated 25 May 2007
Article Copyright 2006 by I@n
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid