Solved

Tlistbox

Posted on 2001-06-29
2
143 Views
Last Modified: 2010-04-06
I want to delete selected items in a list box.


for i := 0 to (ListBox1.Items.Count - 1) do begin
  try
    if ListBox1.Selected[i] then
    begin

  //  I want do remove selected items in this list box here
// is I on the right track or not.
// I now the delete function is not here it is watt I need from you.
    end;
 finally
   
   end;
0
Comment
Question by:Dark_King
2 Comments
 
LVL 6

Accepted Solution

by:
edey earned 50 total points
ID: 6239263
Try this:

var
   ix : integer;
begin
     ix := 0;
     while (ix < listBox1.items.count) do
           if listBox1.Selected[ix] then
              listBox1.items.delete(ix)
           else
               inc(ix);

GL
Mike
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6239267
or

var i: Integer;
begin
  for i := ListBox1.Items.Count - 1 downto 0 do
    if ListBox1.Selected[i] then
      ListBox1.Items.Delete(i);
end;
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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