Deleting a String from a List

From Appmethod Topics
Jump to: navigation, search

Go Up to Manipulating Strings in a List

To delete a string from a string list, call the Delete method of the list, passing the index of the string you want to delete. If you do not know the index of the string you want to delete, use the IndexOf method to locate it. To delete all the strings in a string list, use the Clear method.

The following example uses IndexOf and Delete to find and delete a string:

Object Pascal:

 with ListBox1.Items do
     FoundIndex := IndexOf('bureaucracy');
     if FoundIndex > -1 then


int BIndex = ListBox1->Items->IndexOf("bureaucracy");
if (BIndex > -1)

See Also