For the ones that allow you to set the Text to anything other than the items in the list (like the default csDrowpDown or csSimple) it will just clear the items but, logically enough, the Text will remain as is. If instead you set Style to, say, csDropDownList clearing the items will also clear the Text since there is no item from which to get it.
That's one reason why there exists TComboBox.Clear; whatever the Style it'll clear both the Items and the Text by doing:
which looks like someone came up against your same problem and added that as a "workaround" :D
Title: Re: TCombobox texts are not cleared
Post by: wp on July 22, 2021, 11:45:39 pm
Lazarus behaves like Delphi: - Combobox.Items.Clear clears the dropdown list but keeps the Text (when Style = csDropdown), - Combobox.Clear clears both.
Title: Re: TCombobox texts are not cleared
Post by: lucamar on July 23, 2021, 12:54:11 am
Well, Combobox.Clear does it; Items.Clear, logically enough, only clears the strings in Items. Only when Combobox.Style is csDropDownList (or the equivalent "OwnerDraw" modes) the combo is notified since it means that since ItemIndex is no longer valid there is nothing to show as Text.
Quote
Just checked the trunk in Windows, it clears it all regardless of combo style
As it should if you're talking about Combobox.Clear; otherwise, if you mean Items.Clear, it's clearly a bug.
Title: Re: TCombobox texts are not cleared
Post by: egsuh on July 23, 2021, 03:35:38 am