0

I'm trying to move the checkbox from the first default column in the Listview to the third column. What I've managed to achieve is to get the checkbox to appear but it's non responsive.

With owner draw being turned on. Any help would be appreciated.

I've tried the code in here: drawing a checkbox in a TListView

WilliamFidel
  • 41
  • 1
  • 5
  • Is the post you have posted as an answer, actually the answer? Saying *This is something I've tried* tells me that it should have been a part of your question, right? If so, please edit by moving your attempted code to your question post and deleting your answer post, thank you. – Tom Brunberg Aug 06 '20 at 13:15
  • Thank you for editing your post and removing the "no-answer". But please also explain how the code you now refer to doesn't do what you want. – Tom Brunberg Aug 06 '20 at 13:26
  • 3
    It is very expected that it is non-responsive, because it isn't a checkbox, but an image of a checkbox. – Andreas Rejbrand Aug 06 '20 at 13:30
  • "Native" checkboxes are supported only for the default column. Secondary columns require custom drawing (even the default column just uses a state image, not a true checkbox). To make the checkbox "responsive", you would have to keep track of the check state manually, such as in the `TListItem.Data` property, and have the `OnDrawItem` event draw the checkbox according to the current state. Then handle click events within the ListView, determining if the click coordinates are within the bounds of the checkbox image, and if so then update the tracked state and trigger the ListView to repaint. – Remy Lebeau Aug 06 '20 at 16:40
  • It's not a quick solution for you now, but when you use Delphi, I can really recommend investing some time in learning how to get the most out of Virtual-TreeView... You'll thank yourself for it later. – Wouter van Nifterick Aug 07 '20 at 13:30
  • There are lots of libs that have grids and lists that let you insert TObjects into columns. The standard TListView is an interface to a common Windows control, and I'm guessing it would take a lot of work to create a derived class that does this. Most of the ones I've seen, like in DevEx, start with their own custom grid and go from there. The suggestion for Virtual TreeView may represent your best starting point. – David Aug 09 '20 at 18:19

0 Answers0