method Editor.InsertItem (Value as Long, Caption as String, [Image as Variant], [Parent as Variant])
Inserts a child item to the editor's 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.
Parent as Variant A long expression that defines the value of the parent item.
Use the InsertItem to insert child items to the editor's predefined list. Use the AddItem method to add new items to the editor's list. Use the ExpandItem property to expand an item. Use the ExpandAll items to expand all items. Use the ItemTooltip property to assign a tooltip to a predefined item into a drop down editor.

The following screen show shows a simple hierarchy into a built-in DropDownList editor:

The following VB sample adds a simple hierarchy to a DropDownList built-in editor:

Dim h1 As HITEM
With Grid1
    .BeginUpdate
    .Images ("gBJJgBggAAwAAgACEKAD/hz/EMNh8TIRNGwAjEZAEXjAojJAjIgjIBAEijUlk8plUrlktl0vmExmUzmk1m03nE5nU7nk9n0/oFBoVDolFo1HpFJpVLplNp1PqFRqVTqlVq1XrFZrVbrldr1fsFhsVjslls1ntFptVrtltt1vuFxuVzul1u13vF5vV7vl9v1/wGBwW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45XXy/Nnva6vd7007HJ7MX4Hk7nS7/p9Utskz8vr+Hxono+X1+33/HGig+lX8jiPJAjCRpGjLMpwph/D+lJ+A+lJ8AOlJ4QIjJwJUxECpnCaMgGlUOJMYAEwilR+BylJ/j3Ey3JMgIA=")
    .Images ("gBJJgBggAAwAAgACEKAD/hz/EMNh8TIRNGwAjEZAEXjAojJAjIgjIBAEijUlk8plUrlktl0vmExmUzmk1m03nE5nU7nk9n0/oFBoVDolFo1HpFJpVLplNp1PqFRqVTqlVq1XrFZrVbrldr1fsFhsVjslls1ntFptVrtltt1vuFxuVzul1u13vF5vV7vl9v1/wGBwWDjUPACAxGExVRwzAx0Sf4AxzAyWPxCAxeZouTyGdzmfx+cy+a0k5xuP0+Uw8ZzGVymc0uxmmcw2pjGt2G4x+y3ks2kO12ey2J3MY2G95GF4G/yO24u343D1vJ3m14HW5vX5eh7mv3fU2XMw+J0flxPY4PH8Gl0Xn7XZ+HjzGj23r5H09+d/Hx/f29b0OU+LQNU/0CwNA8EQSm6Kh8lUGo6j6QpGACSJPCqbsNBSVuAk5+Mik54B+lJwAfEYDxNFCTmBE8VAGlJgRdFsXxijRwRojJ4RujB8xKk8OI0gIA==")
    .Columns.Add "Column 1"
    .ColumnAutoResize = True
    .HeaderVisible = False
    With .Items
        h1 = .InsertItem(, , "Child 1") ' Inserts a child itme
        .CellValueFormat(h1, 0) = exHTML
        .CellHasCheckBox(h1, 0) = True   ' Associates a check box to a cell
        .CellValue(h1, 0) = 3            ' Sets the cell's value
        .CellImage(h1, 0) = 1            ' Associates an image to a cell
        With .CellEditor(h1, 0)
            .EditType = DropDownListType
            .DropDownAutoWidth = False
            .AddItem 1, "CObject class", 1
            .InsertItem 2, "CCmdTarget class", 2, 1
            .InsertItem 3, "CWnd class", 3, 2
            .InsertItem 6, "S y n c", 1, 1
            .AddItem 4, "Exceptions", 1
            .InsertItem 7, "System Exceptions", 2, 4
            .AddItem 5, "File Services", 2
            .ExpandAll
        End With
    End With
    .EndUpdate
End With

The following VB samples adds a simple hierarchy to a PickEditType buil-in editor:

With Grid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXGRIDLibCtl.PickEditType
        .AddItem 0, "Organization"
        .InsertItem 1, "UN", , 0
        .InsertItem 2, "ONU", , 0
        .ExpandItem(0) = True
    End With
End With 

The following C++ sample adds a simple hierarchy to a PickEditType built-in editor:

#include "Items.h"
#include "Editor.h"
COleVariant vtMissing; V_VT( &vtMissing) = VT_ERROR;
CItems items = m_grid.GetItems();
CEditor editor = items.GetCellEditor( COleVariant( items.GetFirstVisibleItem() ), COleVariant( long(0) ) );
editor.SetEditType( 14 /*PickEditType*/ );
editor.AddItem( 0, "Organization", vtMissing );
editor.InsertItem( 1, "UN", vtMissing, COleVariant( long(0) ) );
editor.InsertItem( 2, "ONU", vtMissing, COleVariant( long(0) ) );
editor.SetExpandItem( COleVariant(long(0)), TRUE);

The following VB.NET sample adds a simple hierarchy to a DropDownListType built-in editor:

With AxGrid1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXGRIDLib.EditTypeEnum.DropDownListType
        .AddItem(0, "Organization")
        .InsertItem(1, "UN", , 0)
        .InsertItem(2, "ONU", , 0)
        .ExpandItem(0) = True
    End With
End With

The following C# sample adds a simple hierarchy to a DropDownListType built-in editor:

EXGRIDLib.Items items = axGrid1.Items;
EXGRIDLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0);
editor.EditType = EXGRIDLib.EditTypeEnum.DropDownListType;
editor.AddItem(0, "Organization", null);
editor.InsertItem(1, "UN",null,  0);
editor.InsertItem(2, "ONU",null, 0);
editor.set_ExpandItem(0, true);

The following VFP sample adds a simple hierarchy to a DropDownType built-in editor:

with thisform.Grid1.Items
	With .CellEditor(.FirstVisibleItem, 0) 
		.EditType = 14 && PickEdiType
        .AddItem(0, "Organization")
        .InsertItem(1, "UN", , 0)
        .InsertItem(2, "ONU", , 0)
        .ExpandItem(0) = .t.
	EndWith
endwith