diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index 232a12adda..31ad25de09 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -842,6 +842,7 @@ end; procedure TCustomComboBox.UpdateSorted; var lText: string; + lIndex: integer; begin if HandleAllocated then TWSCustomComboBoxClass(WidgetSetClass).Sort(Self, Items, FSorted) @@ -850,7 +851,9 @@ begin // remember text lText := Text; TStringList(FItems).Sorted := FSorted; - ItemIndex := FItems.IndexOf(lText); + lIndex := FItems.IndexOf(lText); + if lIndex >= 0 then + ItemIndex := lIndex; end; end;