Windows common control list methods
- Last UpdatedMar 07, 2025
- 4 minute read
You can use the methods of the Windows common controls to manipulate the controls at run time by using them in scripting.
The following table contains a list of methods you can use in scripting to:
-
Load and save the contents of the Edit Box control from and to a file.
-
Manipulate items in the lists of the List Box control and Combo Box control.
-
Manipulate items in the lists of the List Box control and Combo Box control.
Method
Purpose, syntax and information
AddItem
Purpose: Add an item (coerced to String) to the list. If the list is sorted, then the new item is inserted at the right position and selected. If the list is unsorted, the item is added to the bottom of the list.
Used by: Combo Box, List Box
This function does not work when using an Enum or Array to populate the List Box.
Syntax: ControlName.AddItem(CaptionString);
Info: Adding and Inserting Items into a List
Clear
Purpose: Removes all items from the List. If the list is bound, it clears the bound reference (array or enum).
This function does not work when using an Enum or Array to populate the List Box.
Used by: Combo Box, List Box
Syntax: ControlName.Clear();
Info: Deleting Items from a List
DeleteItem
Purpose: Accepts an index as a parameter and removes that item from the list. The first item in the list has an index of 0.
Used by: Combo Box, List Box
Syntax: ControlName.DeleteItem(Index);
Info: Deleting Items from a List
DeleteSelection
Purpose: Delete the currently selected item from the list.
Used by: Combo Box, List Box
Syntax: ControlName.DeleteSelection();
Info: Deleting Items from a List
FindItem
Purpose: Accepts a string and a Boolean (IgnoreCase) as parameters and returns the index of the first item that matches the string. If IgnoreCase is set to true, case of the SearchString is ignored, if set to false, FindItem considers case when performing the search. The first item in the list has an index of 0.
Used by: Combo Box, List Box
Syntax: ControlName.FindItem(SearchString, IgnoreCase);
Info: Finding an Item in a List
GetItem
Purpose: Returns the item associated with an index supplied as a parameter to this function. The first item in the list has an index of 0.
Used by: Combo Box, List Box
Syntax: ItemCaption = ControlName.GetItem(Index);
Info: Reading the Caption of a Selected Item in a List
InsertItem
Purpose: Inserts the supplied string after the current selection in the List. Does not work if list is sorted.
Used by: Combo Box, List Box
Syntax: ControlName.InsertItem(String);
Info: Adding and Inserting Items into a List
SetItemData
Purpose: Associates a value with an item in the list which index is provided to the function. The first item in the list has an index of 0.
This function only works when UseValuesAsItems is set to false. It does not work when using an Enum or Array to populate the List Box control.
Used by: Combo Box, List Box
Syntax: ControlName.SetItemData(Index,Value);
Info: Associating Items with Values in a List
GetItemData
Purpose: Returns the value associated with the item in the list which index is supplied to the function. The first item in the list has an index of 0.
This function only works when UseValuesAsItems is set to false. It does not work when using an Enum or Array to populate the List Box control.
Used by: Combo Box, List Box
Syntax: Value = ControlName.GetItemData(Index);
Info: Associating Items with Values in a List
LoadList
Purpose: Loads a list of strings from a file which name is passed as parameter to the function. The default location for files is the users folder, for example: c:\documents and settings\username.
The LoadList method does not work when using an Enum or Array to populate the List Box control.
Used by: Combo Box, List Box
Syntax: ControlName.LoadList(FileName);
Info: Loading and Saving Item Lists
LoadText
Purpose: Loads a text from a file into the Edit Box control. The default location for files is the users folder, for example: c:\documents and settings\username.
Used by: Edit Box
Syntax: ControlName.LoadText(FileName);
Info: Configuring Edit Box Methods
SaveList
Purpose: Save a list to a file which name is passed as parameter to the function. The default location for files is the users folder, for example: c:\documents and settings\username.
Used by: Combo Box, List Box
Syntax: ControlName.SaveList(FileName);
Info: Loading and Saving Item Lists
SaveText
Purpose: Saves the current text in the Edit Box control to a file. The default location for files is the users folder, for example: c:\documents and settings\username.
Used by: Edit Box
Syntax: ControlName.SaveText(FileName);
Info: Configuring Edit Box Methods