Working with IComboBox Parts

The following tasks are associated with using an IComboBox* part in visual composition. Tasks that are common to many parts are described in related topics.

Setting the combination box type
To specify the combination box type, open the style property in the IComboBox* property sheet. Then, set one of the following styles on and set the others off:

The default style sets the simpleType style on.

Setting initial contents
To define initial selection choices for the combination box, set the initialContents property in the IComboBox* property sheet. Open the Array of strings prompter window from the value column, then enter the choices.

Setting the initial choice
To define a default selection for the combination box, set the selection property in the IComboBox* property sheet. Specify the 0-based index of the selection in the value column. The corresponding choice in the initialContents property is the default selection.

Getting the selected choice
To copy the text selection from the combination box to an entry field, connect the IComboBox* text attribute to the text attribute of the IEntryField* part.

To copy the index of the selection to a numeric field, connect the IComboBox* selection attribute to the target numeric field.

Adding a choice
To add a new choice from the combination box entry field to the list when a push button is selected, do the following:
  1. Connect the IPushButton* buttonClickEvent feature to an add action of the IComboBox* part. For example, connect to the addAsLast action to add the choice at the end of the list.

  2. Connect the IComboBox* text attribute to the text parameter of the buttonClickEvent-to-addAsLast connection. This provides the entry field text as the parameter for the addAsLast action.

Removing a choice
To remove the selected choice from the combination box list when a push button is pressed, do the following:
  1. Connect the IPushButton* buttonClickEvent feature to the remove action of the IComboBox* part.

  2. Connect the IComboBox* selection attribute to the index parameter of the buttonClickEvent-to-remove connection. This provides the selection index as the parameter for the remove action.


Related procedures
Common Tasks for Control Parts
Setting Part Style Properties
Setting Part Color Properties
Setting Part Font Properties
Setting Part Handlers Properties
Setting Part Framing Properties
Working with VisualAge User Interface Parts

Related references
IComboBox
Property Settings -- IComboBox
Portability -- IComboBox