# ImcComboItems class
{: .no_toc }

The collection of the items of an [**ImageCombo**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/index.md), which its [**ComboItems**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/index.md#comboitems) property returns. Its members are [**ImcComboItem**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/ImcComboItem.md) objects, numbered from 1 in the order of the list, and an item can have a key as well.

```tb check_build check_run arch=win32,win64
Dim Item As ImcComboItem
ImageCombo1.ComboItems.Add , "open", "Open"
ImageCombo1.ComboItems.Add , "save", "Save"
ImageCombo1.ComboItems.Add 1, "new", "New"            ' before the first
For Each Item In ImageCombo1.ComboItems
    Debug.Print Item.Index & " " & Item.Key & " " & Item.Text
Next
' Output:
' 1 new New
' 2 open Open
' 3 save Save
```

A program goes through the items with **For Each**, or by number from 1 to [**Count**](#count). It cannot make an **ImcComboItems** object with **New**.

* TOC
{:toc}

## Numbers and keys

The number of an item is its place in the list. It changes when an item is added before it or removed before it, so a program that keeps a number over such a change keeps the wrong item. A key stays with its item.

A key is any string, and capital and small letters in it are the same: `"Open"` and `"OPEN"` are one key. No two items of a list have the same key. An item needs no key: an empty string is no key, and any number of items can be without one.

```tb check_build check_run arch=win32,win64
ImageCombo1.ComboItems.Add , "open", "Open"
ImageCombo1.ComboItems.Add , "save", "Save"
Debug.Print ImageCombo1.ComboItems("SAVE").Index
ImageCombo1.ComboItems.Remove "open"
Debug.Print ImageCombo1.ComboItems("save").Index
Debug.Print ImageCombo1.ComboItems.Exists("open")
' Output:
'  2
'  1
' False
```

Properties
----------

### Count
{: .no_toc }

The number of items in the list. **Long**, read-only.

### Item
{: .no_toc }

Returns one item. It is the default member, so `ImageCombo1.ComboItems("open")` is `ImageCombo1.ComboItems.Item("open")`.

Syntax: *object*.**Item**( *Index* ) **As ImcComboItem**

*Index*
: *required* The number of the item, from 1 to [**Count**](#count), or its key as a **String**.

A number outside that range raises run-time error 9, and a key that no item has raises run-time error 5. [**Exists**](#exists) asks without an error.

Methods
-------

### Add
{: .no_toc }

Puts an item into the list and returns its [**ImcComboItem**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/ImcComboItem.md).

Syntax: *object*.**Add**( [ *Index* ] [, *Key* ] [, *Text* ] [, *Image* ] [, *SelImage* ] [, *Indentation* ] ) **As ImcComboItem**

*Index*
: *optional* A **Long**: the number the new item gets. The items from that number on move up by one. Without it, or with 0, the item goes after the last one.

*Key*
: *optional* A **String** by which the program can name the item. See [Numbers and keys](#numbers-and-keys).

*Text*
: *optional* A **String**: the text of the item.

*Image*
: *optional* A **Variant**: the number or the key of the picture that the item shows, in the image list of the [**ImageCombo**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/index.md#the-pictures). Without it the item has no picture.

*SelImage*
: *optional* A **Variant**: the number or the key of the picture that the item shows while it is the selected item. Without it, or with 0, the item shows the picture of *Image*. Give a number: see the note under [**SelImage**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/ImcComboItem.md#selimage).

*Indentation*
: *optional* A **Long**: the indentation of the item, in widths of a picture. Without it the item gets the [**Indentation**](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/index.md#indentation) of the control.

An *Index* that is negative or greater than [**Count**](#count) + 1 raises run-time error 35600, *Index out of bounds*. A key for *Image* or *SelImage* that the control's image list does not have raises run-time error 35601, *Element not found*. So does any key when the control has no image list, or was given a handle. A negative number raises 35600. A number is not compared with the number of pictures in the list.

A *Key* that another item has raises run-time error 457, and the list is as it was.

> [!WARNING] 1.8.142.0
> A negative *Indentation* raises run-time error 380 after the item has been put into the collection. The collection then holds the item and the list of the control does not: [**Count**](#count) is one more than the control shows, and the item has no text. Give a value of 0 or more.

### Clear
{: .no_toc }

Removes every item. The text in the text box stays, and the control raises no event.

Syntax: *object*.**Clear**

### Exists
{: .no_toc }

Returns whether the list has an item of a number or a key, so that a program can ask before [**Item**](#item) raises an error.

Syntax: *object*.**Exists**( *Index* ) **As Boolean**

*Index*
: *required* The number or the key to look for.

### Remove
{: .no_toc }

Removes one item. The items after it move down by one. The text in the text box stays, also when the item was the selected one.

Syntax: *object*.**Remove** *Index*

*Index*
: *required* The number or the key of the item.

A number or a key that the list does not have raises run-time error 9 for a number and 5 for a key, as [**Item**](#item) does.

## See Also

- [ImageCombo](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/index.md) class
- [ImcComboItem](/twinBASIC-docs/tB/Packages/Contributed/VBCCR18/ImageCombo/ImcComboItem.md) class -- one item
