LCL: Set TComboBox ItemIndex with duplicate text elements correctly. Issue #28683, patch from AlexeyT.

git-svn-id: trunk@53676 -
This commit is contained in:
juha 2016-12-14 11:14:28 +00:00
parent 569148b092
commit 80328f4ead

View File

@ -930,11 +930,16 @@ procedure TCustomComboBox.RealSetText(const AValue: TCaption);
var
I: integer;
begin
I := FItems.IndexOf(AValue);
if I >= 0 then
ItemIndex := I
else if (not (csLoading in ComponentState)) then
ItemIndex := -1;
// when items have same text, FItems.IndexOf(AValue) gives wrong index. Issue #28683.
I := ItemIndex;
if (I < 0) or (I >= FItems.Count) or (FItems[I] <> AValue) then
begin
I := FItems.IndexOf(AValue);
if I >= 0 then
ItemIndex := I
else if (not (csLoading in ComponentState)) then
ItemIndex := -1;
end;
inherited;
end;