MS-Excel / General Formatting

Creating a Combo Box

If you want to provide the user with the choice of either selecting an item from a list or typing a value, you need to create a combo box control. To set this up in RibbonX, you begin with the <comboBox> element:

<comboBox id="value"
label="value"
imageMso="value"
size="normal|large"
InsertAfterMso="value"
InsertBeforeMso="value"
enabled="true|false"
visible="true|false"
screentip="value"
supertip="value"
keytip="value"
showItemImage="true|false"
showImage="true|false"
showLabel="true|false">
onChange="value"
sizeString="value"
maxLength="value">

The first thing to notice here is that instead of the onAction attribute, the <comboBox> element uses the onChange attribute. This specifies a macro to run whenever the value of the combo box changes (when either a new value is entered in the edit box or a new value is selected in the list).

The other new attributes here are sizeString, a string of characters that determines the width of the edit box (for example, mmmmmmmmmm), and maxLength, which specifies the maximum number of characters that the user can enter into the edit box.

Here's an example:

<comboBox id="cbWindows"
	label="Windows"
	onChange="Module1.cbWindows_OnAction"
	sizeString="mmmmmmmmmm"
	maxLength="20">

The <comboBox> element creates an empty drop-down list. As with the drop-down control, you populate the list with multiple <item> elements.

See "Working with Ribbon Commands at Runtime," later in this tutorial, for an example of a combo box control.

If you want to use just a text box in your custom Ribbon, RibbonX offers the <editBox> element. This control uses most of the same attributes as <comboBox>, including onChange, sizeString,maxLength, and getText (discussed later in this tutorial).

[Previous] [Contents] [Next]