JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Connecting Toolbar Buttons to Menu Items

Typically, toolbar buttons correspond to frequently used menu items. To connect a toolbar to a menu item, you can use that menu item's PerformClick method to make it seem as though the item itself was clicked:

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object,_
    ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)_
    Handles ToolBar1.ButtonClick
    If e.Button Is ToolBar1.Buttons(1) Then
        MenuItem7.PerformClick()
    End If
End Sub

For example, the button labeled "Menu Button" in the ToolBars example on the CD-ROM (see Figure 10.4) corresponds to the Red item in the Color menu, and clicking that button is the same as clicking the Red menu item.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor