ComboBoxGadget()

Syntax

Result = ComboBoxGadget(#Gadget, x, y, Width, Height [, Flags])
Description
Create a ComboBox gadget in the current GadgetList.

Parameters

#Gadget A number to identify the new gadget. #PB_Any can be used to auto-generate this number.
x, y, Width, Height The position and dimensions of the new gadget.
Flags (optional) Flags to modify the gadget behavior. It 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.

Return value

Returns nonzero on success and zero on failure. If #PB_Any was used as the #Gadget parameter then the return-value is the auto-generated gadget number on success.

Remarks

A 'mini help' can be added to this gadget using GadgetToolTip().

The following functions 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.
- ClearGadgetItems(): Remove all the items.
- RemoveGadgetItem(): Remove an item.
- SetGadgetItemText(): Changes the gadget item text.
- SetGadgetItemImage(): Changes the gadget item image (need to be created with the #PB_ComboBox_Image flag).
- GetGadgetState(): Get the index (starting from 0) of the current element.
- GetGadgetText(): Get the (text) content of the current element.
- SetGadgetState(): Change the selected element.
- SetGadgetText(): Set the displayed text. If the ComboBoxGadget is not editable, the text must be in the dropdown list.
- GetGadgetItemData(): Returns the value that was stored with item.
- SetGadgetItemData(): Stores a value with the item.

ComboBoxGadget() supports the following events reported by EventType():
  #PB_EventType_Change   : The current selection of the text in the edit field changed.
  #PB_EventType_Focus    : The edit field received the keyboard focus (editable ComboBox only).
  #PB_EventType_LostFocus: The edit field lost the keyboard focus (editable ComboBox only).

Example

  If OpenWindow(0, 0, 0, 270, 85, "ComboBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ComboBoxGadget(0, 10, 10, 250, 25, #PB_ComboBox_Editable)
    AddGadgetItem(0, -1, "ComboBox editable...")

    ComboBoxGadget(1, 10, 50, 250, 25)
    For Index = 0 To 5
      AddGadgetItem(1, -1, "ComboBox item " + Index)
    Next

    SetGadgetState(0, 0)
    SetGadgetState(1, 2)    ; set (beginning with 0) the third item as active one
  EndIf

See Also

AddGadgetItem(), RemoveGadgetItem(), CountGadgetItems(), ClearGadgetItems(), GetGadgetState(), SetGadgetState(), GetGadgetText(), SetGadgetText() GetGadgetItemText(), SetGadgetItemText(), SetGadgetItemImage() GetGadgetItemData(), SetGadgetItemData()

Supported OS

All

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