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 a predefined value.  If the Editor contains an item with the same value, it will be removed, so the new value/item takes its place.  
   Caption as String A string expression that indicates the caption for the Value. The Caption supports HTML format. If the Caption property includes a | character ( alternative ), the first part indicates the key of the new item to be added, while the rest specifies the associated HTML caption to be displayed on the drop down editor. Currently, the key is used by a DropDownListType editor to specify string codes rather numeric values for the cell's value ( CellValue property ). For instance, Editor.InsertItem(1,"NYC|<b>New York</b> City ",2) inserts a predefined value with the key of "NYC" and displays "New York City" when the cell's CellValue property is "NYC". The Editor.IndertItem(1,"<b>New York</b> City ",2) inserts a new predefined value with no key, so 1 will be used to identify the caption in the CellValue property.  
   Image as Variant A long expression that indicates the index of the item's icon. 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:

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

With G2antt1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXG2ANTTLibCtl.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_g2antt.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 AxG2antt1.Items
    With .CellEditor(.FirstVisibleItem, 0)
        .EditType = EXG2ANTTLib.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:

EXG2ANTTLib.Items items = axG2antt1.Items;
EXG2ANTTLib.Editor editor = items.get_CellEditor(items.FirstVisibleItem, 0);
editor.EditType = EXG2ANTTLib.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.G2antt1.Items
	With .CellEditor(.FirstVisibleItem, 0) 
		.EditType = 14 && PickEdiType
        .AddItem(0, "Organization")
        .InsertItem(1, "UN", , 0)
        .InsertItem(2, "ONU", , 0)
        .ExpandItem(0) = .t.
	EndWith
endwith
 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.