My goal is to update the ItemIndex of a TListBox, in a way that when programmatically adding an item to the list, the corresponding line is outlined on the TListBox.
with MyLstBox do begin
ItemIndex := -1;
for ind := 0 to Pred (Items.Count) do
if InsertedString = Items [ind]) then begin
ItemIndex := Ind;
This code outlines the item that was just inserted, but also maintains the outline of the previous inserted item.
MultiSelect is set to False, so in principle, only one item should be outlined.