![]() |
Desktop Development »
Miscellaneous »
Miscellaneous Controls
Intermediate
IPToolbox: A VS2005-like ToolboxBy I@nA Visual Studio 2005-like ToolBox control which supports almost all features of the original: drag'n'drop, renaming, hiding tabs, items, and disabling items |
C#, Windows, .NET 2.0VS2005, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
|
|
|
|
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.
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();
yourForm.Controls.Add(toolbox1);
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 |
|
|
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 tabOpened, 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:
Toolbox.Save/Toolbox.SaveXml and Toolbox.Load/Toolbox.LoadXml for serializing/deserializing the state of a toolbox Tab.SortItems for sorting items by alphabetical order Tab.Select/Item.Select for selecting tabs/items in a program OnSelectedChanged and public event SelectedChanged for both tabs and items Tab.EnsureVisible/Item.EnsureVisible for scrolling to tab/item Paint, MouseDown, MouseUp events on tabs and items Tab.OnToggleTab and public event Tab.Toggle for handling the toggling of a tab ...and others.
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.
SelectItem event and SelectedItem property ShowPointer property that enables hiding of the pointer AutoScroll property and the ScrollView method for synchronized scrolling of the Toolbox and other controls TransparentColor property for the Item class HitTest method ToolboxService class from .NET instead of my own implementation public and protected properties AllowNestedTabs property) AllowToolboxItems property) OnClick and OnDoubleClick protected methods for Tab and Item objects ColorStyle.None enumeration member (see TabColorStyle property) Item image TextBox for renaming CreateGeneralTab property Tab object to its own collection Tag property for Tab and Item classes Items
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 25 May 2007 Editor: Genevieve Sovereign |
Copyright 2006 by I@n Everything else Copyright © CodeProject, 1999-2009 Web13 | Advertise on the Code Project |