Discussion:
CheckBox in CListCtrl
(too old to reply)
Chris
2005-08-31 12:23:25 UTC
Permalink
Hi

I'm trying to add a CheckBox in a column of a CListCtrl (but not for a whole
row as with LVS_EX_CHECKBOXES) using images.

Here is my code to setup the list control:
CImageList *m_pImageListCheckBoxes = new CImageList();
VERIFY(m_pImageListCheckBoxes->Create(IDB_CHECKBOXES, 16, 3, RGB(255, 0,
255)));
m_list.SetImageList(m_pImageListCheckBoxes, LVSIL_SMALL);
The checkboxes.bmp file has 3 images: nothing, checked, unchecked

Then I try to set the item in the list, the checkboxes must be in the third
column:
VERIFY(m_list.SetItem(i, 2, LVIF_IMAGE, NULL, 3, my_boolean_data?1:2,
LVIS_STATEIMAGEMASK, 0));

It runs fine but nothing is displayed in the third column. What am I missing
here?

Regards
Chris
Tom Serface
2005-08-31 14:38:17 UTC
Permalink
http://www.codersource.net/mfc_clistctrl_checkbox.html
http://www.codeproject.com/listctrl/xlistctrl.asp
http://www.codeguru.com/Cpp/controls/listview/checkboxes/article.php/c917/

Hopefully one of these articles gives you some help.

Tom
Post by Chris
Hi
I'm trying to add a CheckBox in a column of a CListCtrl (but not for a whole
row as with LVS_EX_CHECKBOXES) using images.
CImageList *m_pImageListCheckBoxes = new CImageList();
VERIFY(m_pImageListCheckBoxes->Create(IDB_CHECKBOXES, 16, 3, RGB(255, 0,
255)));
m_list.SetImageList(m_pImageListCheckBoxes, LVSIL_SMALL);
The checkboxes.bmp file has 3 images: nothing, checked, unchecked
Then I try to set the item in the list, the checkboxes must be in the third
VERIFY(m_list.SetItem(i, 2, LVIF_IMAGE, NULL, 3, my_boolean_data?1:2,
LVIS_STATEIMAGEMASK, 0));
It runs fine but nothing is displayed in the third column. What am I missing
here?
Regards
Chris
Loading...