Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAllow the user to customize a toolbar
Keywordstoolbar, customization
CategoriesControls, Software Engineering
 
When the user selects the Customize\Toolbar command, the program displays a dialog allowing the user to select the tools that should be available. When the user clicks OK, it saves the changes to the Registry and calls subroutine MakeButtons.

MakeButtons clears the toolbar's button collection. Then for each button selected, it adds a new button to the toolbar. It takes the buttons' images and Key values from the ilstToolbarImages ImageList control. It gets the buttons' description and tooltip text from the images' Tag properties.

 
' Create the appropriate toolbar buttons.
Public Sub MakeButtons()
Dim btn As Button
Dim i As Integer

    ' Start from scratch.
    Toolbar1.Buttons.Clear

    ' Make the selected buttons.
    For i = 1 To NumButtons
        If ButtonSelected(i) Then
            ' Create the button with the desired picture.
            Set btn = Toolbar1.Buttons.Add(, _
                ilstToolbarImages.ListImages(i).Key, _
                , tbrDefault, i)

            btn.ToolTipText = _
                ilstToolbarImages.ListImages(i).Tag
            btn.Description = _
                ilstToolbarImages.ListImages(i).Tag
        End If
    Next i
End Sub
 
When the user clicks a toolbar button, the ButtonClick event handler fires and displays the button's Key.
 
Private Sub Toolbar1_ButtonClick(ByVal Button As _
    ComctlLib.Button)
    MsgBox Button.Key
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated