如果利用CListBox实现CCheckListBox?(译)

实现步骤如下:

 

1. 在对话框上添加一个CListBox控件,修改其属性:

  •     Owner Draw = Fixed
  •     Has Strings设置checked;

2. 利用class wizard添加一个变量:

 CListBox  m_ctlCheckList;


将其修改为:
CCheckListBox m_ctlCheckList; 3. 将下面一句从DoDataExchange(CDataExchange* pDX)宏中称到宏外:
DDX_Control(pDX, IDC_LIST1, m_ctlCheckList);
4. 开OnInitDialog上添加如下:
m_ctlCheckList.SetCheckStyle(BS_CHECKBOX);
5. 添加LBN_SELCHANGE事件
int nSel = m_ctlMenuList.GetCurSel(); if(nSel != LB_ERR) { int nCheck = m_ctlCheckList.GetCheck(nSel); m_ctlMenuList.SetCheck(nSel, !nCheck); }

你可能感兴趣的:(如果利用CListBox实现CCheckListBox?(译))