DComboBox
This control allows the user to select one item from a pre-set list of items, or optionally type in an item that it not in the list. It is similar to dDropdownList, except that this control contains an editable textbox for user-entered information.
It normally appears as a single line displaying the selected item, along with an arrow button which the user clicks to "drop down" the full list. When a selection is made from that list, the list disappears, leaving the single-line control. Because its full list isn't displayed until the user selects it, it is ideal for presenting a selection without taking up a lot of area on the screen.
Some of the more useful properties:
- AppendOnEnter - (bool): When this is
True, any item the user types into the textbox is automatically appended to the list ofChoiceswhen they press theEnterkey. There are two hook methods:beforeAppendOnEnter() andafterAppendOnEnter(). These get automatically called before and after the new item is appended to theChoiceslist. ThebeforeAppendOnEnter()method gives you a chance to manipulate the user-entered value, and optionally prohibit the addition by returningFalsefrom the method. TheafterAppendOnEnter()method gives you a chance to do post-processing. - Choices - (list): This determines the options available for the control.
- Keys - (dict / list / tuple): Value that is associated with the
Choices. Many times you want to present the user with a list of choices that mean something to them, but internally in your program, you really need the ID or primary key or some other identifying value that is associated with the choice that the user made. The easiest way to set up theKeysproperty is to make it a 1:1 list of values that correspond position-wise to theChoiceslist. This way, when the user selects, say, the third choice in the list,KeyValuewill return the third value in theKeyslist. - StringValue - (str): Returns the text displayed by the control for the selected item.
- PositionValue - (int): Returns the position of the selected item in the list of available
Choices. - KeyValue - (varies): Returns the value in
Keysthat corresponds to the selected item. - UserValue - (str): Represents the text typed in by the user.
UserValuecan differ fromStringValue, which would mean that the user has typed in arbitrary text. UnlikeStringValue,PositionValue, andKeyValue, settingUserValuedoes not change the currently selected item in the list portion of dComboBox. - ValueMode (str): Can be one of
String,Position, orKey. Determines the result returned by accessing theValueproperty: eitherStringValue,PositionValueorKeyValue. You can always refer to any of those different value types, but when you know which value your program will be needing, you can setValueMode, and afterwards just have the normalValuebinding work correctly.
See the Dabo Class Documentation for an exhaustive documentation of this control's Properties, Events and Methods. (Note that this documentation is no longer live, but it's still available via the Internet Archive).