kidego9436 0 Posted September 30 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'; Share this post Link to post
DelphiUdIT 154 Posted September 30 The first Item of a list (ITEMS -> ItemIndex) is ZERO not ONE. 17 minutes ago, kidego9436 said: ComboEdit1.Items.Clear; ComboEdit1.Items.Add('A'); ComboEdit1.ItemIndex := 1; ComboEdit1.Items.Clear; ComboEdit1.Items.Add('A'); ComboEdit1.ItemIndex := 0; <---------- SHOULD BE 0 Share this post Link to post
jakicex571 0 Posted September 30 He is on something there… i noticed the same issue in one of my projects. Change the first itemindex to 0 and try it again. The exception raises while setting the text property in the rtl. Share this post Link to post
Dave Nottage 549 Posted September 30 1 hour ago, jakicex571 said: The exception raises while setting the text property in the rtl. I confirm the behaviour Share this post Link to post