Solved

Find & Delete String in Listbox

Posted on 1998-01-26
3
304 Views
Last Modified: 2010-08-05
How do I find and delete a string in a listbox?  The delete method needs an integer, so how do I match the Integer to the String?
0
Comment
Question by:d4jaj1
3 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1357610
First you list throught the list to find the string and get it's index, and then you delete it using he index you've got
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1357611
I know that - what I don't know is how to find a string literal in the listbox?
0
 
LVL 3

Accepted Solution

by:
philipleighs earned 10 total points
ID: 1357612
If your list box is called ListBox1 and you want to delete an item called "delete me" from the list, you can do this:

  var Index: Integer;
begin
Index := ListBox1.Items.IndexOf('delete me');
if Index > -1 then
    ListBox1.Items.Delete(Index);
end;

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question