Download demo project - 15 KbDownload source files - 4 Kb
<!-- Article Starts -->
I had a desire/requirement on a recent project to have a CCheckListbox class that allowed for
more than one checkbox in front of the string. The 3-state style set by the CCheckListbox
simply didn't do what I wanted or needed. I had a list of people who could fall into 2 different
categories at the same time. The 3-state style told me that this person fell into one category,
but I had to just know WHICH one.
So, I decided to write a class that extended the capabilities of the CCheckListbox. What I
came up with was the CMultiCheckListBox class. What it does is add another checkbox
in front of the original checkbox in the CCheckListbox implementation.
To use the class, follow these steps:
- Add a member variable to the desired class (CDialog, CFormView, etc.)
- Subclass the list box variable just created.
void CCharityReportDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_LIST1, m_List);
- To set the first checkbox for listbox item nIndex, call SetCheck(nIndex, nCheck)
- To set the second checkbox, call SetMultiCheck(nIndex, nCheck)
- To retrieve the checkbox state of the first checkbox, call GetCheck(nIndex)
- To retrieve the checkbox state of the second checkbox, call GetMultiCheck(nIndex)