0

I want to create a new component in Delphi inherited from TDBLookupComboBox. My only question is, how can I replace the control which is shown when the ComboBox is dropped down and show a TCheckListBox instead? Is this a Win-Api combined with a popup? And how can I change the Popup look like a normal TWinControl? Thanks!

Sam
  • 139
  • 1
  • 12
  • You can't. TDBLookupComboBox is a descendant of TCustomComboBox, which means you can't replace that portion. Write your own descendant of TCheckListBox and add the datalinks to make it data aware. You can use the source code of TDBLookupComboBox to see how to add those datalinks. – Ken White Feb 19 '23 at 23:40
  • Thanks for the answer. How can I change TCheckListBox to behave like a TComboBox. Or can I inherit from TComboBox and change the Dropdown to TCheckListBox? Would that be easier and if how can I archive this? – Sam Feb 19 '23 at 23:49
  • No, as I've already said in my previous comment, you cannot inherit from TComboBox. You can't replace its dropdown, which is why I suggested you write your own component. Asking us to write it for you is unreasonable. You can write a TComboBox descendant and use owner-draw to draw checkboxes for the items, but you'd also have to write your own code that handled checking and unchecking them and tracking the checked value of each item. This sounds like an XY problem, though - if you need the ability to allow multiple items, a TBLookupCombo would be the wrong contol anyway. – Ken White Feb 19 '23 at 23:51
  • I'm not asking for writing code for me! I was just asking for ideas or some api functions or whatever is necessary for this. – Sam Feb 20 '23 at 00:10

0 Answers0