mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 10:40:20 +02:00
LCL: Set TComboBox ItemIndex with duplicate text elements correctly. Issue #28683, patch from AlexeyT.
git-svn-id: trunk@53676 -
This commit is contained in:
parent
569148b092
commit
80328f4ead
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user