Add-in for Excel project. Ribbon is XML-based. I added a drop-down to the Ribbon:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab label="MyTab" id="tab0">
<group id="MyGroup"
<dropDown id="MyItems" label="My Items"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
How do I fill in the drop-down with items?
Thank you
There are two possible ways to define the dropdown control on the ribbon:
1. Static. For example:
<dropDown id="ddStatic" label="Static dropdown">
<item id="ddItem1" label="Item 1" imageMso="HappyFace"/>
<item id="ddItem2" label="Item 2" imageMso="Info"/>
</dropDown>
2. Dynamic. You need to specify ribbon callbacks, for example, the getItemCount
should look like the following one:
C#: int GetItemCount(IRibbonControl control)
VBA: Sub GetItemCount(control As IRibbonControl, ByRef count)
C++: HRESULT GetItemCount([in] IRibbonControl *pControl, [out, retval] long *count)
Visual Basic: Function GetItemCount(control As IRibbonControl) As Integer
It determines how many items will appear in a drop-down.
Also you may need to implement the getItemID
, getItemLabel
- sets the label for items in a drop-down, getSelectedItemIndex
- returns the index of the selected item, getSelectedItemID
, onAction
- fires when an item is selected in a drop-down. You may find these callbacks described in the following series of articles in MSDN:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.