diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index c50588ed16..b73ec46f17 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -38,7 +38,7 @@ begin // and use the interface based list FItems := NewStrings; - if FItemIndex <> -1 then + if (FItemIndex > -1) and (FItemIndex < FItems.Count) then TWSCustomComboBoxClass(WidgetSetClass).SetItemIndex(Self, FItemIndex); TWSCustomComboBoxClass(WidgetSetClass).SetStyle(Self, FStyle); TWSCustomComboBoxClass(WidgetSetClass).SetArrowKeysTraverseList(Self, FArrowKeysTraverseList);