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 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.AddItem(1,"NYC|<b>New York</b> City ") adds a predefined value with the key of "NYC" and displays "New York City" when the cell's CellValue property is "NYC". The Editor.AddItem(1,"<b>New York</b> City ") adds 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.   

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

 


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