A multi-check ListBox | CodeGuru

A multi-check ListBox

  Download Source Code and Example project 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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 24, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

CMultiCheckListBox example 
Download Source Code and
Example project

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.)
     CMultiCheckListBox m_List; 
    
  • Subclass the list box variable just created.
    
    
     void CCharityReportDlg::DoDataExchange(CDataExchange* pDX)
     {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CCharityReportDlg)
        DDX_Control(pDX, IDC_LIST1, m_List);
        //}}AFX_DATA_MAP
     }
                
    
  • To set the first checkbox for listbox item nIndex, call SetCheck(nIndex, nCheck)
     m_List.SetCheck(nIndex,1); 
    
  • To set the second checkbox, call SetMultiCheck(nIndex, nCheck)
     m_List.SetMultiCheck(nIndex,1); 
    
  • To retrieve the checkbox state of the first checkbox, call GetCheck(nIndex)
     m_List.GetCheck(nIndex); 
    
  • To retrieve the checkbox state of the second checkbox, call GetMultiCheck(nIndex)
     m_List.MultiGetCheck(nIndex); 
    

Last updated: 4 July 1998

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.