Combobox

Note

Combobox is derived from Control class.

The Combobox control is used to display data in a drop-down combo box. By default, the Combobox control appears in two parts: the top part is a text box that allows the user to type a list item. The second part is a list box that displays a list of items from which the user can select one.


Constructor

Combobox class has a complex constructor:

object Combobox:new {
               object Parent, string Name,
               table Choices = { "item 1", "item 2", "item3" }
       }

Events

The following events are emitted by this class:

Event name Description
Widget.onEnter When the mouse moves onto this widget.
Widget.onLeave When the mouse moves out to this widget.
Combobox.onSelected_ When an item on the list is selected or the selection changes.

Inherited Methods

These methods are inherited from its super classes:

Class Method Description
Object:getName Returns object’s name.
Object:setName Sets the object name.
Widget:getParent Returns object’s parent.
Widget:setParent Sets the object parent.
Widget:getPosX Returns object’s position related to X.
Widget:setPosX Sets the object position related to X.
Widget:getPosY Returns object’s position related to Y.
Widget:setPosY Sets the object position related to Y.
Widget:getWidth Returns object’s width.
Widget:setWidth Sets the object width.
Widget:getHeight Returns object’s height.
Widget:setHeight Sets the object height.
Widget:getwxObj Returns the wxWidgets object.

Class Methods

These methods are defined by this class.

Combobox:getText

Returns the current value in the combobox text field.
string Combobox: getText ( )

Combobox:setText

Set the current value in the Combobox.
nil Combobox: setText( string sText )

Combobox:setChoices

Set the current choices in the Combobox.
nil Combobox:setChoices ( table tChoices )

Combobox:getchoices

Returns a table of control choices.
table Combobox:getChoices( )

Combobox:setSelection

Sets the selection to the given item nSelect.

Note that this does not cause any command events to be emitted nor does it deselect any other items in the controls which support multiple selections.

nil Combobox:setSelection( number nSelect )

Combobox:getSelection

Returns the index of the selected item or wx.wxNOT_FOUND if no item is selected.

Returns: The position of the current selection

This method can be used with single selection list boxes only, you should use Listbox:getSelections() for the listboxes with LB_MULTIPLE style.

number Combobox:getSelection()

Combobox:findItem

Finds and returns a reference to a ListItem object in a Combobox control.
number Combobox:findItem( number nItem )

Combobox:clear

Clear all items in the Combobox.