I have a ListView with the columns ‘Name’, ‘Expected’, ‘Total’, and I want to add another column saying ‘Recount’ at the end. The ‘Recount’ column will ideally have a checkbox only if the ‘Expected’ value is larger than the ‘Total’ value.
So far I have got the ListView with columns and can add a check box on the left hand side, but that check box is not under a column heading (though I can probably put another column with no values in there to work around that) and it is on all of the records.
Anyone have any ideas what else I can do?
This is actually relatively simple to implement, provided that you’re willing to endure the drudgery of P/Invoke to access functionality built into the native Windows control, but not exposed by the .NET FW.
I demonstrate in my answer here how this exact same thing can be done with a TreeView control, and considering how similar a ListView is to a TreeView, it should not be particularly surprising that this can be done in very much the same way with a ListView.
Here’s all the code that is required (make sure that you’ve added an
Importsdeclaration for theSystem.Runtime.InteropServicesnamespace):And then you can simply call the above method like this:
Producing something that looks a bit like this (after clicking the “Hide Check” button for both the tomato and the cucumber items):