Click here to Skip to main content
Click here to Skip to main content

A VS.Net-like ToolBox

, 19 Sep 2002
Rate this:
Please Sign up or sign in to vote.
This is a Visual Studio .NET like ToolBox control with animation and drag and drop support.

Sample Image

Introduction

This is a Visual Studio .NET like ToolBox control. It has all the animations of the original plus some more. It is very customizable as you can see in the snapshot. I copied the icons and tabs from the real ToolBox so it looks just like the original.

The public methods

ToolBox(Size sz,int Button_Height,ContextMenu Menu)
  • sz -Needed Specifies the size of the ToolBox.
  •  
  • Button_Height -Optional Specifies the Height of the Buttons. If it is negative the default value is used
  •  
  • Menu -Optional Specifies the ListView`s context menu.
void AddTab(string Caption,int ImgIndex,ImageList ImgList)
void AddTab(ToolBoxTab Tab) 
  • AddTab adds another category to the ToolBox.
void AddItem(string Caption,int ImageIndex,int TabIndex)
void AddItem(ToolBoxItem Item, int TabIndex)
  • AddItem adds an item to the specified Tab in TabIndex
ToolBoxTab GetTab(int Index)
  • GetTab retrievs the ToolBoxTab object at the given index
int GetTabCount()
  • Returns the number of Tabs.
bool RemoveTab(int Index)
  • Removes the Tab specified in Index
bool RemoveItem(int TabIndex, int ItemIndex)
  • Removes the Item specified at the given indexes.
void Compress()
  • Makes the ToolBox to retreat.
void Expand()
  • Makes the ToolBox to Expand.
void EndAllMovement()
  • Stops all Tab movement.
bool ScrollUp()
  • Scrolls the visible ListView up one item if possible
bool ScrollDown()
  • Scrolls the visible ListView down one item if possible.
bool SetSize(Size sz)
  • Modifies the size of the ToolBox.

 

These are the main methods except three that I will explain here:

public delegate void OnToolBoxClick(int TabIndex,int ItemIndex);
public delegate void OnToolBoxTabChanged(int TabIndex);
public delegate void OnToolBoxStateChanged(int State);

These delegate types are events that the ToolBox sends. For example if you want to know when the current Tab is changed you do the following:

  1. Implement a method in your application like this:
    void OnTBTabChanged(int TabIndex)
  2. In when you init the ToolBox you need to let the ToolBox know what function to call when the event triggers:
    tb.SetTabChangedDelegate(new ToolBox.OnToolBoxTabChanged(OnTBTabChanged));
    Now your method will be called every time a new Tab is selected and receives the Tab`s index that you can use with the GetTab method.

     

The SetDelegate methods are:

void SetClickDelegate(OnToolBoxClick OnTBxClick)
  • This method sets the delegate method that is called when an item of the ListView is clicked.
void SetTabChangedDelegate(OnToolBoxTabChanged OnTBTabChange)
  • This method sets the delegate method that is called when a new Tab is selected
void SetStateChangedDelegate(OnToolBoxStateChanged OnTBStateChange)
  • This method sets the delegate method that is called when the state of the ToolBox changes. For example see the status Label in the Demo application.

 

The state of the ToolBox can be one of the following:

  1. ToolBox.States.Compressed = 1
  2. ToolBox.States.Compressing = 2
  3. ToolBox.States.Extended = 3
  4. ToolBox.States.Extending =4
enum States {Compressed=1,Compressing,Extended,Extending};

These are all the public methods.

The Properties

int DelayBeforeRetreat
  • This gets/sets the amount of time in miliseconds before the ToolBox starts to retreat when the mouse is no longer over it.
string DragDropSeparatorText
  • This gets/sets the Separator text between the Tab text and the Item text when Drag&Drop is performed
  • The default is ".".
SelectedTab
  • Tihs gets/sets the selected Tab. If a new tab is specified it will act like it was clicked by the user
int State
  • This gets the state of the ToolBox. if you want to change it's state call the Extend and Compress methods.
int TabAcceleration
  • This gets/sets the Tab movement acceleration
  • Default it is 2.
int TabTime
  • This gets/sets the time of the Tab movement in miliseconds.
int TimerInterval
  • This gets/sets the refresh timer interval.
string TitleText
  • This gets/sets the Title of the ToolBox.
Image ToolBoxImage
  • This gets/sets the Image used on the left of the ToolBox.

Adding a ToolBox to your application

This is very simple. Just do the following:

  1. Add a reference of the ToolBoxLib.dll.
  2. Add the following line of code at the beginning of your application:
  3. using ToolBoxLib
  4. Declare a variable of type ToolBox.
  5. In the constructor, after the InitializeComponent(); set the Toolbox's parameters.

Here is an example:

tb = new ToolBox(new Size(200,ClientRectangle.Height-28),18,ToolBoxContextMenu);
tb.Location = new Point(0,28);

tb.SetClickDelegate(new ToolBox.OnToolBoxClick(OnTBClick));
tb.SetTabChangedDelegate(new ToolBox.OnToolBoxTabChanged(OnTBTabChanged));
tb.SetStateChangedDelegate(new ToolBox.OnToolBoxStateChanged(OnTBStateChanged));
tb.Show();
this.Controls.Add(tb);
tb.BringToFront();

License

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

Share

About the Author

Iulian Serban

Romania Romania
I am 18 years old and I have programmed for one year in C++ and MFC.
I am now programming in C# and .NET Framework.

Comments and Discussions

 
QuestionNeed help PinmemberAlitrix-kms4-Nov-14 20:01 
QuestionGRATITUDE Pinmember4season12-Aug-14 2:31 
Questionhow to do same using VB PinmemberMember 826548924-Sep-11 23:03 
GeneralCould you please select a license and attach to the project PinmemberCoderider19-Jan-10 9:22 
GeneralNeed VB.NET Version Pinmemberkolag18-Nov-07 23:10 
GeneralReally Excellent Pinmemberkolag31-Oct-07 1:58 
QuestionHow can i move toolbar in the form? Pinmembersangram120-Oct-06 2:55 
GeneralMenu Pinmemberpatshiva15-Sep-05 23:52 
Generaltoolbox docking PinmembervrushaliD10-Jan-05 19:37 
GeneralRightToLeft Pinmemberperspolis29-Oct-04 23:32 
GeneralProblem with XP Home Version PinmemberCodingNDallas18-Feb-04 7:27 
GeneralPanels instead of TreeList PinsussVitolini13-Dec-03 21:19 
GeneralRe: Panels instead of TreeList Pinmemberfunvill1-Aug-04 19:27 
GeneralSelected Item PinsussAnonymous16-Jul-03 5:53 
QuestionWhat happens if I resize the Toolbox? PinmemberMikeI12-Jun-03 0:58 
AnswerRe: What happens if I resize the Toolbox? PinmemberIulian Serban12-Jun-03 5:15 
GeneralComments PinmemberMr.FB20-Mar-03 7:24 
GeneralRe: Comments PinmemberIulian Serban20-Mar-03 7:38 
GeneralRe: Comments PinmemberMr.FB21-Mar-03 10:00 
GeneralA Few Things PinmemberDamage_Inc11-Mar-03 0:46 
GeneralRe: A Few Things PinmemberDamage_Inc11-Mar-03 4:36 
GeneralExcellent example, comment about European programmer's PinmemberBJavierto8-Jan-03 6:07 
GeneralRe: Excellent example, comment about European programmer's PinmemberIulian Serban10-Jan-03 11:52 
QuestionHow to keep an item selected? PinmemberJeffrey Ganping Chen14-Dec-02 19:52 
AnswerRe: How to keep an item selected? PinmemberIulian Serban18-Dec-02 11:22 
GeneralRe: How to keep an item selected? PinmemberJeffrey Ganping Chen18-Dec-02 13:22 
GeneralLicensing and Distribution Pinmemberflipdoubt11-Dec-02 6:20 
GeneralRe: Licensing and Distribution PinmemberIulian Serban11-Dec-02 11:39 
GeneralSelectedTab PinsussAnonymous11-Nov-02 10:02 
GeneralRe: SelectedTab PinmemberIulian Serban11-Nov-02 10:22 
GeneralRe: SelectedTab PinmemberIulian Serban12-Nov-02 8:21 
GeneralVB.NET PinmemberBrent Landry6-Nov-02 8:47 
GeneralRe: VB.NET PinsussBrent Landry6-Nov-02 9:45 
GeneralRe: VB.NET Pinmemberrober.pareja31-Jan-03 6:42 
GeneralRight To Left Pinsusspourheidar4-Nov-02 20:51 
GeneralJust a question PinmemberVdC24-Sep-02 2:42 
GeneralRe: Just a question PinmemberIulian Serban24-Sep-02 9:11 
GeneralWell Done. PinmemberMStanbrook23-Sep-02 7:37 
GeneralRe: Well Done. PinmemberIulian Serban23-Sep-02 9:35 
GeneralGreat, I love it :) PinmemberJohn O'Byrne20-Sep-02 12:06 
GeneralRe: Great, I love it :) PinmemberIulian Serban20-Sep-02 22:20 
GeneralVery nice! PinmemberMark Conger20-Sep-02 10:46 
GeneralRe: Very nice! PinmemberIulian Serban20-Sep-02 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web04 | 2.8.150414.1 | Last Updated 20 Sep 2002
Article Copyright 2002 by Iulian Serban
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid