method Editor.AddItem (Value as Long, Caption as String, [Image as Variant])
Adds a new item to editor's predefined list.

TypeDescription
Value as Long A long expression that defines an unique predefined value
Caption as String A string expression that specifies the HTML caption associated with the value. The format of the Caption parameter is "key|caption¦caption¦...¦caption", which indicates an item with the giving key / identifier, which displays multiple captions.

The Caption allows using the following special characters:

  • | character (pipe, vertical bar, ALT + 126) defines the key or identifier of the item to add. Currently, the key is used by a DropDownListType editor to specify string codes rather numeric values for the cell's value ( CellValue property )
  • ¦ character (vertical broken bar, ALT + 221) defines captions for multiple columns. The ¦ character can be escaped, so \¦ displays the ¦ character (available for DropDownType, DropDownListType and PickEditType editors, 20.0+)

For instance:

  •  "<b>New York</b> City" defines the "New York City" item
  •  "NYC|<b>New York</b> City" the "New York City" item with the "NYC" as key or identifier
  • "NYC|<b>New York</b> City¦783.8 km˛¦8.42 mil" defines the "New York City" item with the "NYC" as key or identifier and sub-captions 783.8 km˛ and 8.42 mil (in separated columns)
  • "<b>New York</b> City¦783.8 km˛¦8.42 mil" defines the "New York City" item and sub-captions 783.8 km˛ and 8.42 mil (in separated columns)
Image as Variant A long expression that indicates the index of the item's icon (1-based). Use the Images method to assign a list of icons to the control.

Use the AddItem method to add new items to the editor's predefined list. Use the InsertItem method to insert child items to the editor's predefined list. If the AddItem method uses a Value already defined, the old item is replaced. The AddItem method has effect for the following type of editors: DropDownType, DropDownListType, PickEditType, and CheckListType. Check each EditType value for what Value argument should contain. Use the RemoveItem method to remove a particular item from the predefined list. Use the ClearItems method to clear the entire list of predefined values. Use the SortItems to sort the items. Use the ItemToolTip property to assign a tooltip to a predefined item into a drop down list. Use the Refresh method update immediately the cell's content when adding new items to a drop down list editor. The Caption parameter supports HTML tags listed here here.  

The following VB sample adds items to a CheckListType editor:

With Grid1
    With .Columns.Add("CheckList").Editor
        .EditType = CheckListType
        .AddItem &H1, "ReadOnly", 1
        .AddItem &H2, "Hidden", 2
        .AddItem &H4, "System", 3
        .AddItem &H10, "Directory", 4
        .AddItem &H20, "Archive", 5
        .AddItem &H80, "Normal", 7
        .AddItem &H100, "Temporary", 8
    End With
.Items.AddItem &H1 + &H2
End With

The following VB sample adds predefined values to drop down list editor:

With Grid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = DropDownListType
        .AddItem 0, "No border", 1
        .AddItem 1, "Single Border", 2
        .AddItem 2, "Double Border", 3
    End With
End With

The following C++ sample adds predefined values to drop down list editor:

With Grid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = DropDownListType
        .AddItem 0, "No border", 1
        .AddItem 1, "Single Border", 2
        .AddItem 2, "Double Border", 3
    End With
End With

The following VB.NET sample adds predefined values to drop down list editor:

With AxGrid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXGRIDLib.EditTypeEnum.DropDownListType
        .AddItem(0, "No border", 1)
        .AddItem(1, "Single Border", 2)
        .AddItem(2, "Double Border", 3)
    End With
End With

The following C# sample adds predefined values to drop down list editor:

EXGRIDLib.Items items = axGrid1.Items;
EXGRIDLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0);
editor.EditType = EXGRIDLib.EditTypeEnum.DropDownListType ;
editor.AddItem(0, "No border", 1);
editor.AddItem(1, "Single border", 2);
editor.AddItem(2, "Double border", 3);

The following VFP sample adds predefined values to drop down list editor:

with thisform.Grid1.Items
	With .CellEditor(.FirstVisibleItem, 0) 
		.EditType = 3 && DropDownList
        .AddItem(0, "No border", 1)
        .AddItem(1, "Single Border", 2)
        .AddItem(2, "Double Border", 3)
	EndWith
endwith