RAD Studio |  |

Deleting a String from a List
See Also
Collapse All

To delete a string from a string list, call the list's Delete method, passing the index of the string you want to delete. If you don't 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:

Copy Code

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

Copy Code

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

See Also

Manipulating Strings in a List

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!