JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Creating Toolbar Drop-down Buttons

Drop-down buttons are one of the most useful styles of toolbar buttons; these buttons can display a drop-down menu if you click their down arrow. To add a menu to a drop-down button, you can create a menu, such as a context menu, and assign that menu to the drop-down button's DropDownMenu property. To see how this works, take a look at the ToolBars example on the CD-ROM. I've added a context menu, ContextMenu1, to that example, with three menu items: Red, Blue, and Green, and implemented the event handlers for these items like this:

Private Sub MenuItem1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MenuItem1.Click
    MsgBox("You clicked Red")
End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MenuItem2.Click
    MsgBox("You clicked Blue")
End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MenuItem3.Click
    MsgBox("You clicked Green")
End Sub

All that remains is to assign ContextMenu1 to the DropDownMenu property of the drop-down button in the toolbar, which you can do with the ToolBarButton Collection Editor, which you open with the Buttons property in the properties window. That's all it takes; you can see the active drop-down button at work in Figure 10.4.

Related solution:

Found on page:

Creating Context Menus

404

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor