for I := 0 to ListBox1.Items.Count -1 do begin if ListBox1.Selected[I] then ListSelectItem := I; ListBox1.Selected[I] := False; end; ListBox1.Selected[ListSelectItem] := True;
VB.NET code:
for I = 0 to ListBox1.Items.Count -1 do if ListBox1.Selected[I] is True then ListSelectItem = I else ListBox1.Selected[I] = False end if end for ListBox1.Selected[ListSelectItem] = True