• Welcome to ForumKorner!
    Join today and become a part of the community.

[Delphi] delete things in a listbox

djfshady

Member
Reputation
0
To Delete all selected items in a Listbox:

Code:
procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin for i := ListBox1.Items.Count - 1 downto 0 do if ListBox1.Selected[i] then ListBox1.Items.Delete(i); end;

To delete MULTIPLE selected items in a list box:
you must make sure ListBox1.MultiSelect = true

Code:
var ii : integer; begin with ListBox1 do begin for ii := -1 + Items.Count downto 0 do if Selected[ii] then Items.Delete(ii) ; end; end;
 
Top