A checkbox is in reality simply 2 different state images (one for the
checcked box and one for the unchecked box) that are taken from a system
supplied image list and applied to the listview item as appropriate.
Unfortunately .NET doesn't provide an event for when the state image index
changes so you'll have to override WndProc and handle the LVN_ITEMCHANGING
notification. Here's code that does most of this (in VB.NET):
http://groups.google.se/group/micro...dowsforms.controls/msg/5afb5ede99eb3ffc?hl=sv
However, this code checks for changes to the selected state flag
(LVIS_SELECTED). Change this to check for the new state image index instead
(different bits in the state parameter) and return 1 to prevent the change
(0 to allow it). The state image index is 1 for the unchecked box and 2 for
the checked one. If you set it to 0 the checkbox will be removed
Read more using the following keywords: LVITEM, INDEXTOSTATEIMAGEMASK,
LVN_ITEMCHANGING, NMLISTVIEW
The following code should give you the state image index provided the code
in the link above (still in VB.NET):
((nmlv.uNewState And &HF000) >> 12)
/claes