[SOLVED] TCombobox texts are not cleared lazarus / 31-LCL ---------------------------------------------------------------------- egsuh · 2021-07-22 12:08 I populate TCombobox is populated, and select an item, and then I clear all items. But the text of selected item is still live. I have to set ItemIndex to -1 before clearing items to remove text as follows (Lazarus 2.0.10,  Windows 10). Combobox1.ItemIndex := -1; Combobox1.Items.Clear; ---------------------------------------------------------------------- zoltanleo · 2021-07-22 12:33 @egsuh Try Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Combobox1.Clear; ---------------------------------------------------------------------- lucamar · 2021-07-22 17:53 The result of: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Combobox1.Items.Clear;depends on the Style of the ComboBox. 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: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomComboBox.Clear;begin  Items.Clear;  Text:='';end;which looks like someone came up against your same problem and added that as a "workaround" ---------------------------------------------------------------------- wp · 2021-07-22 21:45 Lazarus behaves like Delphi: - Combobox.Items.Clear clears the dropdown list but keeps the Text (when Style = csDropdown), - Combobox.Clear clears both. ---------------------------------------------------------------------- lucamar · 2021-07-22 22:54 Quote from: jamie on July 22, 2021, 11:23:06 pmActually, the Clear should work all around.. 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. QuoteJust 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. ---------------------------------------------------------------------- egsuh · 2021-07-23 01:35 Combobox1.Clear; Clears all. Thank you for all your comments.