Solved

If Listbox1 string exist in Listbox2 then the item should be deleted

Posted on 2009-03-30
1
293 Views
Last Modified: 2012-05-06
Hey all,

I've got a Listbox1 and Listbox2.

Both are filled with about 50-100 strings and sometimes they contain the same string, if they do I would like for (via button1.click) all the items in Listbox1 that already exist in Listbox2 to be deleted from Listbox1.
0
Comment
Question by:MerlaP83
1 Comment
 
LVL 14

Accepted Solution

by:
SteveBay earned 125 total points
ID: 24020379

procedure TForm1.Button1Click(Sender: TObject);
var i : Integer;
begin
     for i := 0 to ListBox1.Items.Count -1 do
          begin
          if ListBox2.Items.IndexOf(ListBox1.Items[i]) > -1 then
               ListBox2.Items.Delete(ListBox2.Items.IndexOf(ListBox1.Items[i]));
          end;
end;

Open in new window

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

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 214
Help on project with Soap 10 63
Dev Express grid collapse 2 47
Drag & Drop... Data from one grid to another 2 47
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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