Windows Common Control List Methods
- Last UpdatedSep 27, 2022
- 3 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);
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: Delete 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: Delete items from a list
DeleteSelection
Purpose: Delete the currently selected item from the list.
Used by: Combo Box, List Box
Syntax: ControlName.DeleteSelection();
Info: Delete items from a list
FindItem
Purpose: Accepts a string as a parameter and returns the index of the first item that matches the string. The first item in the list has an index of 0.
Used by: Combo Box, List Box
Syntax: ControlName.FindItem(SearchString);
Info: Find 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);
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);
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);
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);
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: Load and save 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: 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: Load and save 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: Edit Box methods