Hello everyone,
I've encountered an "List index out of bounds (0). TStringList is empty."-bug in my Delphi (FMX) application when executing the following code for a ComboEdit:
//Prepare the ComboEdit:
ComboEdit1.Items.Clear;
ComboEdit1.Items.Add('A');
ComboEdit1.ItemIndex := 1;
//Do Stuff...
//Change the Content later again:
ComboEdit1.Items.Clear;
ComboEdit1.Text := 'B';
It seems that the error originates from the "TComboEditModel.DoValidate(const Value: string);"-method in the "FMX.ComboEdit.pas"-file.
In line 446 is an "if" that causes the exception:
if (ItemIndex <> -1) and (Text <> Items[ItemIndex]) then
"ItemIndex" has the Value "0" in the debugger.
My Workaround would be to add a "ItemIndex := -1" to my Code, but thats some kind of ugly to add it everywhere:
//Prepare the ComboEdit:
ComboEdit1.Items.Clear;
ComboEdit1.Items.Add('A');
ComboEdit1.ItemIndex := 1;
//Do Stuff...
//Change the Content later again:
ComboEdit1.Items.Clear;
ComboEdit1.ItemIndex := -1;
ComboEdit1.Text := 'B';