Berocoder 14 Posted October 27, 2019 I want to develop an own component for TCombobox. It should work like this: 1. User type something in the field2. User type magic keys, in my case ",," to trigger the search for typed characters3. My event OnTrig is called. That search in SQL in the database for the characters. So this can be any tables in the database and is customized per instance of the component.4. The list of hits is displayed in the combobox. If too many the first 99 hits is displayed5. The user picks one of the hits in the combobox. Now the event OnPick is triggered. That is, of course, different per instance and transform the hit to an object in application.Now could you give some general advice about how I should proceed? I have bought Devexpress VCL components so have source for that. Maybe better to use any of those comboboxes as base? Regards Roland Bengtsson Share this post Link to post
aehimself 396 Posted October 27, 2019 You don't need a component for this. I'd proceed this way: - have a strict private DateTime variable. Upon form creation, set it to zero. - OnKeyDown / OnKeyPress handler of the ComboBox. If the key was pressed, and it's not a comma, set the above DateTime to zero. If it is, check if the value of the DateTime variable: - If the value equals zero, set it to Now - If it's not, check the seconds passed between that and Now (DateUtils.SecondsBetween): - If the difference is greater than 1 or 2, set the variable to Now - If the difference is less, execute your custom action. If you need more help let me know, I can make a quick demo, but my theory would be this. Share this post Link to post
Guest Posted October 28, 2019 On 10/27/2019 at 7:45 AM, Berocoder said: I have bought Devexpress VCL components so have source for that. Maybe better to use any of those comboboxes as base? DX do have this functionality for their TcxExtLookupComboBox and TcxLookupComboBox. But... in order to make it work the way you are aiming at (pulling refined SQLs) you would need to use their "ServerDatsControllers" OR implement a couple of GUI-oriented event handlers and put your SQL together there (not 100% cool model-wise). Their "ServerDataController" do not covering the stuff 100%. If you can find a solution to make your client have all the data,DX controls are splendid. But all the chrome-goodies works best when data is already local. Also - i have not used their ServerDataControllers myself. Share this post Link to post