Adds a new item to the list array (list box or combo box control).
object.AddItem(Item, Index)
Newlook Smartclient
Newlook Server
Item - (String, Required)
String value specifying the text component of the item.
Index - (Integer, Optional)
The position within the collection to create the new item. If this value is zero the item will be added to the start of the list.
If the control's Sorted property is set to True then each item will be given an index that corresponds to its sort order in the list and any index specified in the Index argument will be ignored. The NewIndex property can then be used to determine the index of a newly inserted item.
The ListCount property can be used to determine the number of items in the list array.
Adding an item using this method causes the index of every subsequent item in the list and the count property of the list items collection to increment by 1.
The following example will add the item that the user has entered into a textbox name "tbNewItem" to the bottom of the combo box list. JSCRIPTfunction AddUserText() { //Add the text entered to the list var newItem = App.ActiveForm.Controls.tbNewItem.Text; var newItemIndex = App.ActiveForm.Controls.cbComboBox.ListCount;
addNewSuccess = App.ActiveForm.Controls.cbComboBox.AddItem(newItem, newItemIndex); }
VB SCRIPTSub AddUserText ' Add the user-entered text to the bottom of the list NewItem = App.ActiveForm.Controls.tbNewItem.Text NewItemIndex = CInt(App.ActiveForm.Controls.cbComboBox.ListCount) AddNewSuccess = App.ActiveForm.Controls.cbComboBox.AddItem (NewItem,NewItemIndex) End Sub |
List property (ComboBox) | List property (ListBox) | RemoveItem method | Clear method - ComboBox | Clear method - ListBox
© 2004-2021 looksoftware. All rights reserved.