TbrButtonMenu class
One item of the menu that a drop-down button of a ToolBar shows: its text, its state, an optional picture, or a separator line in its place. A program gets one from the TbrButtonMenus collection, and from that collection’s Add method.
Dim Button As TbrButton, Item As TbrButtonMenu
Set Button = ToolBar1.Buttons.Add(, "paste", "Paste", TbrButtonStyleDropDown)
Set Item = Button.ButtonMenus.Add(, "plain", "Paste as plain text")
Item.Checked = True
Button.ButtonMenus.Add , , "-"
Button.ButtonMenus(2).Separator = True
Debug.Print Item.Parent.Key; ": "; Item.Text
Debug.Print Button.ButtonMenus(2).Separator
' Output:
' paste: Paste as plain text
' True
A program cannot make a TbrButtonMenu object with New. The user’s choice of an item raises the toolbar’s ButtonMenuClick event with the item. The menu is made from the items each time the button opens it, after ButtonDropDown has been raised, so a handler of that event can still change the items.
Properties
Checked
Whether the item has a check mark. Boolean. Default: False.
Enabled
Whether the user can choose the item. Boolean. Default: True. A disabled item is drawn greyed.
Index
The number of the item in the TbrButtonMenus collection and in the menu, from 1. Long, read-only. It changes when an item is added or removed before this one.
Key
The key of the item in the collection. String. Empty for an item without a key.
An assignment gives the item another key, and the collection no longer finds it by the old one. A key that another item of the button has raises run-time error 457, and the item keeps its key.
Parent
The button that has the item. A TbrButton, read-only.
Picture
A picture drawn beside the text of the item. An icon or a bitmap, as a picture object. Default: Nothing. The item keeps a copy.
Separator
Whether the item is a horizontal line that divides the menu, in place of a choice. Boolean. Default: False. A separator ignores Text, Enabled, Checked and Picture, and the user cannot choose it.
Tag
A value of the program’s own, which the toolbar does not use. Variant: it holds a value of any type, an object included, which is assigned with Set. A new item has an empty string.
Text
The text of the item. String. It is the default member. An ampersand before a letter makes the letter the item’s mnemonic in the menu.
Visible
Whether the menu shows the item. Boolean. Default: True. A hidden item takes no place in the menu, and the numbers of the other items do not change.
See Also
- ToolBar class
- TbrButton class – the button that has the menu
- TbrButtonMenus class – the collection of the items