marcos.digirotas Posted September 13, 2018 Share Posted September 13, 2018 I have a Combobox which needs to be repopulated dinamically, that is, the user type 3 characters in the ComboBox and press the return key. In this moment a query is executed and the Combobox needs to be populated with the items resulted by that query. The problem that I found is that the ComboBox.Items.Clear doesn't have the expected effect. Here is a simple example: Add a TUniComboBox On the OnKeyDown method, add the code: if Key=VK_RETURN then begin UniComboBox1.Items.Clear; UniComboBox1.Items.Add('RIO DE JANEIRO'); UniComboBox1.Items.Add('RIO GRANDE DO SUL'); UniComboBox1.Items.Add('RIO GRANDE DO NORTE'); end; Run the program Inside the ComboBox, type "RIO" and press the return key: it will appear 3 items at the ComboBox Edit the typed text to "RIOS" and press the return key again In this moment I expected that the Combobox was cleared and populated with the 3 options, but the result obtained is that the ComboBox has 6 items, as if the "UniComboBox1.Items.Clear" instruction had been ignored. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 13, 2018 Share Posted September 13, 2018 Hi, if Key=VK_RETURN then begin UniComboBox1.BeginUpdate; UniComboBox1.Items.Clear; UniComboBox1.Items.Add('RIO DE JANEIRO'); UniComboBox1.Items.Add('RIO GRANDE DO SUL'); UniComboBox1.Items.Add('RIO GRANDE DO NORTE'); UniComboBox1.EndUpdate; end; 1 Quote Link to comment Share on other sites More sharing options...
marcos.digirotas Posted September 14, 2018 Author Share Posted September 14, 2018 Thanks Sherzod, It works perfectly! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.