1

I need to add checkbox control to the listcontrol subitems .First I will let you know what I did,Initially i added a listcontrol of report style and added checkbox style to the listview as follows.

m_MfpListControl.SetExtendedStyle(LVS_EX_CHECKBOXES);

This step of code is adding checkboxes to the first most column.But,I want to add checkbox to the subitems randomly like as,

Column1 | Column2 | Column3 | COlumn4


[]Item1 | []subitem1 | []subitem2 | [] subitem3

[]-Represents Checkbox

Adding for the "Item1" is not a big deal but adding to the subitems making me down and moreover I tried in manny ways like as after inserting item ,I am setting the state for the particular item as,

m_MfpListControl.SetItemState(0,INDEXTOSTATEIMAGEMASK(3),LVIS_STATEIMAGEMASK);

But this also didn't work fine ,as I am able to add and remove the checkbox for the first column ,I tried in a way of applying the same methodology like setting the item state as I had done using "SetItemState()" API in order to add the checkbox control to the subitems ,unfortunately it is not working in case of subitems.

Can anyone please let me know the right approach so that I should be able to add checkboxes to the subitems.

3
  • Have you tried setting setting the LVS_EX_SUBITEMIMAGES? You would need to provide a check box image.
    – rrirower
    Jun 5, 2014 at 12:19
  • Custom-draw or Owner-draw is the only way to get subitem checkbox functionality. Jun 6, 2014 at 2:28
  • Yes I checked using LVS_EX_SUBITEMIMAGES it is just adding the checkbox image to the subitems,but what I want is I must be able to select the checkbox and uncheck it. Can please let me know how to this owner draw as I am new to mfc .If possible elaborate me with a piece of code . Jun 6, 2014 at 6:43

1 Answer 1

0

I use this class to add check boxes on subitems:

http://www.codeproject.com/Articles/8112/CQuickList

It requires LVS_OWNERDATA. In my case, it's not a problem.

This class also adds check boxes on subitems, but without LVS_OWNERDATA:

http://www.codeproject.com/Articles/29064/CGridListCtrlEx-Grid-Control-Based-on-CListCtrl

Vinicius

1
  • Doesn't we have any solution other than this.I looked at the links you had provided but it's so huge .I tried debugging that application and tried setting of checkboxes but each and every method has some link with the other and it's growing like anything .Can you please let me know anyother way to add the piece of code that could generate only checkboxes to the subitems in my project :) Jun 12, 2014 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.