Is there any way to insert the checkboxes into the CListBox. Let's say, I have 10 lines in the ClistBox. I would like to see each line has its own checkbox in front.
Thanks for your reply Somebody has told me this before. But, how to use CChecklistbox. As far as I concern, the CChecklistbox is inherited from CListBox. I am sorry, my knowledge in Visual C++ is very limited. Please help! MAny thanks!
- Add a ListBox to your dialog box
- Modify its properties: in the 'Style' tab, select 'Owner Draw' as fixed and check 'Has Strings'
- Use class wizard to build a variable for the Listbox. Say you call it m_List
- Modify the m_List declaration like this:
CCheckListBox m_List;
- Add some code to populate the listbox:
m_List.AddString( "Item 0"
m_List.AddString( "Item 1"
m_List.AddString( "Item 2"
m_List.AddString( "Item 3"
- To get the checked item(s), use code like this:
for ( int nItem = 0; nItem < m_List.GetCount(); nItem++)
{
if ( m_List.GetCheck( nItem))
{
CString str;
str.Format( "Item %d is Checked ", nItem);
AfxMessageBox( str);
}
}
HTH
Thierry
BTW: read the doc for additional info about CCheckListBox class ...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.