Class

WebToolbarMenu


Warning

This item was deprecated in version 2021r3. There is no replacement.

Description

A button with a popout menu in a WebToolbar. Clicking it will display a menu. The button cannot use the toggled appearance that a WebToolbarButton has.

Property descriptions


WebToolbarMenu.Badge

Badge As String

A small graphical element used to displayed additional information alongside the WebToolbarItem.

The text appears in white on a round rectangle with a red background.


WebToolbarMenu.Caption

Caption As String

The text of the label for the toolbar menu button. The Caption is displayed below the icon if there is one.

The Caption can be surrounded by "<raw></raw>" tags to temporarily disable HTML parsing. For example, you could bold just a single word in a Caption by doing this:

button.Caption = "<raw><b>bold</b></raw> text"

This code changes the caption for an existing menu button on the toolbar:

Var button As WebToolbarMenu
button = WebToolBarMenu(Toolbar1.ItemWithName("ChartsButton"))

If button <> Nil Then
  button.Caption = "New Caption"
End If

WebToolbarMenu.Enabled

Enabled As Boolean

Used to set the item to appear enabled or disabled. If True, the item is enabled.

This code changes disables an existing menu button on the toolbar:

Var button As WebToolbarMenu
button = WebToolBarMenu(Toolbar1.ItemWithName("ChartsButton"))

If button <> Nil Then
  button.Enabled = False
End If

WebToolbarMenu.Icon

Icon As Picture

A 32 x 32 pixel icon that is displayed in the toolbar menu. Setting the icon to nil will cause the item to have no icon, and the appearance will be adjusted accordingly.

This code changes the icon for an existing menu button on the toolbar:

Var button As WebToolbarMenu
button = WebToolBarMenu(Toolbar1.ItemWithName("ChartsButton"))

If button <> Nil Then
  button.Icon = ChartIcon ' ChartIcon is an icon added to the project
End If

WebToolbarMenu.Menu

Menu As WebMenuItem

This property needs to be set to the menu to be displayed when the user clicks the item.

This example populate the WebToolbarMenus ChartsButton in the Open event of the WebToolbar:

' Create the chart menu
Var chartMenu As New WebMenuItem
chartMenu.Append(New WebMenuItem("Line"))
chartMenu.Append(New WebMenuItem("Bar"))
chartMenu.Append(New WebMenuItem("Pie"))
chartMenu.Append(New WebMenuItem("-"))
chartMenu.Append(New WebMenuItem("3D Line"))
chartMenu.Append(New WebMenuItem("3D Bar"))
chartMenu.Append(New WebMenuItem("3D Pie"))

' Assign the menu to the WebToolbarMenu button by looking it up by name
WebToolBarMenu(Me.ItemWithName("ChartsButton")).Menu = chartMenu

WebToolbarMenu.Tag

Tag As Variant

A hidden value associated with the WebToolbarItem.

Since this is a Variant, this can be used to associate any type of data, even an object, with the WebToolbarItem.


WebToolbarMenu.Tooltip

Tooltip As String

A helpful message that describes the purpose of the WebToolbarItem.


WebToolbarMenu.Visible

Visible As Boolean

Indicates whether or not the WebToolbarItem is visible.

This property is useful when you need to hide/show WebToolbarItem's dynamically at runtime.

Notes

See the WebControl.Shown event for an example of populating a menu. It is assigned to a WebToolbarMenu via setting the Menu property. Menu selections are handled by the WebToolbar.MenuAction event. See that event for an example.

Sample code

This example populate the WebToolbarMenus ChartsButton and DatesButton in the Open event of the WebToolbar:

' Create the chart menu
Var chartMenu As New WebMenuItem
chartMenu.Append(New WebMenuItem("Line"))
chartMenu.Append(New WebMenuItem("Bar"))
chartMenu.Append(New WebMenuItem("Pie"))
chartMenu.Append(New WebMenuItem("-"))
chartMenu.Append(New WebMenuItem("3D Line"))
chartMenu.Append(New WebMenuItem("3D Bar"))
chartMenu.Append(New WebMenuItem("3D Pie"))

' Assign the menu to the WebToolbarMenu button by looking it up by name
WebToolBarMenu(Me.ItemWithName("ChartsButton")).Menu = chartMenu

' Create the Dates menu
Var dateMenu As New WebMenuItem
dateMenu.Append(New WebMenuItem("Today"))
dateMenu.Append(New WebMenuItem("Tomorrow"))
dateMenu.Append(New WebMenuItem("Next Week"))
dateMenu.Append(New WebMenuItem("Next Month"))

' Assign the menu to the WebToolbarMenu button by looking it up by name
WebToolBarMenu(Me.ItemWithName("DatesButton")).Menu = dateMenu

Menu selection is handled in the MenuAction event of the toolbar. In this case, the event handles both menus. Because it handles actions from several menus, the event is passed two parameters, Item As WebToolbarMenu and Choice As WebMenuItem. In this case, the event handler is:

Select case Item.Name
Case "ChartsButton"
    LastAction.Text = "You selected " + choice.Text + " from the Charts menu."
Case "DatesButton"
    LastAction.Text = "You selected " + choice.text + " from the Dates menu."
End Select

Compatibility

Web projects on all supported operating systems.