Combo Box class

Properties of the Combo Box class are as follows:

Property

Explanation

items

This property returns the contents of the combo box. To help you get started faster, it is predefined with a list of items that you can edit. If your combo box will contain a fixed list of items, update the list here. If the list is dynamic and changes by responding to different map events, it should be set in one of the other functions and must be removed from the __init__ function.

editable

This property returns the state of the combo box, where, by default, it is set to True. When set to True, the user can type a new value not present in the list of options. When it is False, the user can only choose from the options provided in the combo box.

enabled

This property returns the availability of the combo box, where, by default, it is set to True. When set to False, the combo box is unavailable. This property allows you to write logic to test the state of the desktop application in order to disable or enable the combo box. For example, you might have a combo box that requires a data layer to be loaded in ArcMap before it is accessible.

dropdownWidth

This property sets the combo box's drop-down width. The specified drop-down width is used to define the length of this drop-down box. The drop-down width's value is represented with any character, repeated the number of times desired for the length of the drop-down box as the user will see it after clicking the Down arrow on the combo box.

width

This property sets the length of the combo box by using any character and repeating that character to represent the number of characters visible in the combo box. For example, if you want the combo box to show five characters, the width property will have a value of WWWWW.

value

This property gets or sets the value of the combo box. After setting a value, use the Refresh() method to ensure it is visible in the edit portion of the control.

The following are functions of the Combo Box class:

Function

Explanation

__init__(self)

Occurs when the defined combo box is initialized by the desktop application. This is a Python built-in function, referred to as the constructor, where some initial variables can be initialized. By default, the items, editable, and enabled properties of the combo box are set for you.

onSelChange(self, selection)

Occurs each time a new selection is made in the combo box. selection specifies the value selected by the user.

onEditChange(self, text)

Only applicable when the editable property is set to True and occurs each time a new character is typed into the combo box. text specifies the text being entered by the user.

onFocus(self, focused)

Only applicable when the editable property is set to True. Occurs each time the combo box gets focus or loses focus. focused specifies the focused state of the combo box. It is a Boolean that returns True when the combo box has focus or False when the combo box does not have focus.

onEnter(self)

Only applicable when the editable property is set to True. Occurs each time the user presses the ENTER key when inputting to the edit box of the combo box. This allows you to wait for the user to finish typing a value before attempting to process your business logic based on the value added.

Refresh(self)

Refreshes the combo box after a value is set. Refreshing the combo box will ensure the value is visible in the edit portion of the control.

Related Topics

3/3/2014