SetMenu

Description

Sets a menu to the button in the RibbonBar control.

Applies to

RibbonApplicationButtonItem, RibbonTabButtonItem, RibbonLargeButtonItem, RibbonSmallButtonItem controls

Syntax

For RibbonApplicationButtonItem:

controlname.SetMenu ( RibbonApplicationMenu ApplicationMenu )

For RibbonTabButtonItem, RibbonLargeButtonItem, and RibbonSmallButtonItem:

controlname.SetMenu ( RibbonMenu Menu )

Argument

Description

controlname

The name of the RibbonApplicationButtonItem, RibbonTabButtonItem, RibbonLargeButtonItem, or RibbonSmallButtonItem control.

ApplicationMenu

The RibbonApplicationMenu item you want to set.

Menu

The RibbonMenu item you want to set.


Return value

Integer.

Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is null, returns null.

Usage

A RibbonApplicationMenu control can contain a master menu and a recent menu. The master menu can have no more than two levels. The recent menu can have only one level; and can contain no more than 9 items. Only the menu item with the "Normal" or "Separator" type (that is RibbonMenuItem with ItemType 0 or 1) can be added as a master menu item. Only the menu item with the "Recent" type (that is RibbonMenuItem with ItemType 2) can be added as a recent menu item. See InsertMasterItem and InsertRecentItem for more.

A RibbonMenu control can contain menu items in no more than two levels. Only menu items with the "Normal" or "Separator" type (that is RibbonMenuItem with ItemType 0 or 1) can be added to the RibbonMenu control. See InsertItem for more.

Example 1

This example sets a menu to the "MyApp" application button. The menu includes an "Account" master menu item and a "RecentItem1" recent menu item.

Integer li_Return
RibbonApplicationButtonItem lr_AppButton
RibbonApplicationMenu lr_AppMenu

lr_AppMenu.InsertMasterItemFirst ("Account", "AccountBig!", "ue_AccountMenuClicked")
lr_AppMenu.InsertRecentItemFirst ("RecentItem1", "ue_RecentMenuClicked")
lr_AppButton.Text = "MyApp"
li_Return = lr_AppButton.SetMenu (lr_AppMenu)
If li_Return = 1 Then
 li_Return = rbb_1.SetApplicationButton (lr_AppButton)
End If

Example 2

This example sets a menu to a tab button. The menu includes an "Add" menu item.

Integer li_Return
RibbonTabButtonItem lr_TabButton
RibbonMenu lr_Menu

lr_Menu.InsertItemFirst ("Add", "AddSmall!", "Ue_AddMenuClicked")
li_Return = lr_TabButton.SetMenu (lr_Menu)

See also

GetMenu

GetMenuByButtonHandle