Click here to Skip to main content
13,000,742 members (47,991 online)
Click here to Skip to main content
Add your own
alternative version


70 bookmarked
Posted 2 Feb 2009

User Customizable ToolStrip with Drag and Drop

, 21 May 2010
Rate this:
Please Sign up or sign in to vote.
With this .NET library, you can implement a customize toolbar function in your application.


With this library, written in VB.NET, you can add a 'Customize Toolbar' function to your application.


I needed a customize toolbar function in my application, but I really couldn't find any library for .NET to implement this. So, I decided to write my own and share it to help others.

Using the Code

Add a reference to the DLL file. In the DLL, there is a class named CustomizeToolStrip. To use the library, you should make an instance of this class. Then you can set three things:

  • ToolStrip - The ToolStrip you want a customize function for
  • LanguageStrings - A Dictionary with strings used in the dialog
  • DefaultSetting - A String containing the code which is used when the user clicks the Reset button

To show the customize dialog, use ShowDialog(). This is a function which returns a String which you can save in your settings.
The second function is to reload the ToolStrip if you have saved the result of the ShowDialog() function. The ToolStrip is reloaded with the buttons/separators as the code in the String says.

Implementing the Customize Toolbar Function

If you just want to add the functionality with the basic functions, this code will do the complete job. Add it to the handler of a button, for example.

Dim t As UserCustomizableToolStrip.CustomizeToolStrip
t.ToolStrip = ToolStrip1
Dim chosenSetting = t.ShowDialog()

Then, you can save chosenSetting in My.Settings, for example. When loading your application, you can reload the ToolStrip again (assuming your Setting is called ToolStripSetting):

Dim t As UserCustomizableToolStrip.CustomizeToolStrip
t.ToolStrip = ToolStrip1

Adding a DefaultSetting to Enable the Reset Button

If you wish to add a Reset button, you obviously need to supply a default value in case the Reset button is clicked. This is a code as described above.

Adding a LanguageStrings to Use Another Language

In case you need to change the wording in the dialog, you can set other Strings in the LanguageStrings, which is a Dictionary. For example, a Dutch version would be:

Dim lang As New Dictionary_
	(Of UserCustomizableToolStrip.CustomizableToolStripLanguageStrings, String)

lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.Add, _
	"Toevoegen ->")

	AvailableToolBarButtons, "Beschikbare items:")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.Cancel, _
	CurrentToolBatButtons, "Huidige items:")

    (UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.MoveDown, "Omlaag")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.MoveUp, "Omhoog")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.OK, "OK")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.Remove, _
	"<- Verwijderen")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.Reset, _
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.Separator, _
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.TitleBar, _
	"Werkbalk aanpassen")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.WarningText, _
	"Weet u zeker dat u de werkbalk wilt herstellen naar de beginwaarden?")
lang.Add(UserCustomizableToolStrip.CustomizableToolStripLanguageStrings.WarningTitle, _
	"Werkbalk aanpassen")

t.LanguageStrings = lang

More About the Code of the Chosen Setting

The code that the ShowDialog function returns (and which you have to supply for the Reset button) has a very simple lay-out:


Each item (Item1, ...) corresponds to either a ToolStripItem or equals the word Separator. The order of the items is the order of which the buttons and separators appear in the ToolStrip.

Points of Interest

I'm only 14 years old, and I'm happy I managed to write this code. If you use this component in your application, please let me know about it. I'd love to see my component in action.


  • Please do not use the word 'Separator' as the name of any of your ToolStripItems
  • Not implemented - Nothing



  • 21-05-2010
    • Rewritten most of the code, enhancing the simplicity of the use
  • 06-02-2009
    • Reset button
    • .Name used instead of .Tag (you don't have to specify the .Tag properties anymore)
    • Fixed some issues with the demo
  • 02-02-2009
    • First release


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


About the Author

Netherlands Netherlands
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMessage Removed Pin
Sajjad Altahan1-Aug-13 15:28
groupSajjad Altahan1-Aug-13 15:28 
QuestionDownload but reset button is missing Pin
AACINC5-Jan-12 9:46
memberAACINC5-Jan-12 9:46 
AnswerRe: Download but reset button is missing Pin
pimb25-Jan-12 11:05
memberpimb25-Jan-12 11:05 
GeneralRe: Download but reset button is missing Pin
AACINC6-Jan-12 2:37
memberAACINC6-Jan-12 2:37 
GeneralMy vote of 5 Pin
Member 840416715-Nov-11 21:33
memberMember 840416715-Nov-11 21:33 
GeneralNice work - suggestions for improvements Pin
TobiasP15-Feb-09 9:27
memberTobiasP15-Feb-09 9:27 
Nice work, this could be a very useful piece of code and the article is well written too. Given your age you obviously cannot have been a programmer very long, and that makes it even more impressive. I have a few suggestions for improvements though, hopefully they help you develop your skills further:
  • Unless you have a very specific reason, specifying arguments and variables as arrays are a bad idea - they can almost always be replaced with a generic IList instead.

  • There should be no need to handle the separators as a special case - the ToolStripSeparator class inherits from the ToolStripItem class and should obey by the same rules.

  • Instead of actually removing tool strip items from the ToolStrip, you can set the Visible property to false for the items that should not be displayed (as long as you don't intend to move tool strip items between different toolstrips).

The first point still allows you to use arrays if you want to, so there should be no need to change code that uses the methods, but allows greater flexibility (you could as an example add the contents of a tool strips Item property directly as argument). The second point should allow you to use the "Separator" string in any tool strip item. The third point should allow you to skip the Buttons() argument to both ShowCustomizeToolbarWindow and UpdateToolStripWithString, because the set of available buttons are always the buttons specified by the tool strips Items collection. (Moving the position of an item in the ToolStripItemCollection can be done by first removing it and then inserting it at the correct position, instead of simply adding it.)
GeneralRe: Nice work - suggestions for improvements Pin
pimb215-Feb-09 9:37
memberpimb215-Feb-09 9:37 
GeneralRe: Nice work - suggestions for improvements Pin
TobiasP15-Feb-09 10:39
memberTobiasP15-Feb-09 10:39 
GeneralRe: Nice work - suggestions for improvements Pin
pimb216-Feb-09 4:29
memberpimb216-Feb-09 4:29 
GeneralGreat job! Pin
Shane Story6-Feb-09 4:03
memberShane Story6-Feb-09 4:03 

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 | Terms of Use | Mobile
Web01 | 2.8.170624.1 | Last Updated 21 May 2010
Article Copyright 2009 by pimb2
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid