ComboBoxGadget()

Syntax

Result = ComboBoxGadget(#Gadget, x, y, Width, Height [, Flags])
Description
Create a ComboBox gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget number will be returned as 'Result'. #Gadget will be the number returned by EventGadget() command. Once a ComboBox is created, its list of items is empty.
The Height parameter should be a larger value than the main body of the gadget, since it also sets the height of the drop down list part of the ComboBox.

You can add a 'mini help' to this gadget by using GadgetToolTip().

The following commands can be used to act on the list contents:

- AddGadgetItem(): Add an item.
- GetGadgetItemText(): Returns the gadget item text.
- CountGadgetItems(): Count the items in the current combobox.
- ClearGadgetItemList(): Remove all the items.
- RemoveGadgetItem(): Remove an item.
- SetGadgetItemText(): Changes the gadget item text.

- GetGadgetState(): Get the index (starting from 0) of the current element.
- GetGadgetText(): Get the (text) content of the current element.
- SetGadgetState() can be used to change the selected element.
- SetGadgetText(): Set the displayed text. If the ComboBoxGadget is not editable, the text must be in the dropdown list.

'Flags' are always optional and can be composed (using the '|' operator) of one of the following constants:
  #PB_ComboBox_Editable  : Makes the ComboBox editable
  #PB_ComboBox_LowerCase : All text entered in the ComboBox will be converted to lower case.
  #PB_ComboBox_UpperCase : All text entered in the ComboBox will be converted to upper case.
Example:
  If OpenWindow(0, 0, 0, 270, 140, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    ComboBoxGadget(0, 10, 10, 250, 100, #PB_ComboBox_Editable)
    AddGadgetItem(0, -1, "ComboBox editable...")
    ComboBoxGadget(1, 10, 40, 250, 100)
    For a = 1 To 5 : AddGadgetItem(1, -1,"ComboBox item " + Str(a)) : Next a
    SetGadgetState(1, 2)    ; set (beginning with 0) the third item as active one
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- CloseGadgetList() - Gadget Index - ContainerGadget() ->