如何展示复选框
//LVS_EX_CHECKBOXES每一行的最前面带个复选框//LVS_EX_FULLROWSELECT整行选中//LVS_EX_GRIDLINES网格线//LVS_EX_HEADERDRAGDROP列表头可以拖动m_listctl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES);
全选,全不选,反选实现
// 全选
for (int i = 0; i < m_listctl.GetItemCount(); i++) {m_listctl.SetCheck(i, TRUE);m_listctl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
}// 全不选
for (int i = 0; i < m_listctl.GetItemCount(); i++) {m_listctl.SetCheck(i, FALSE);m_listctl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
}//反选
BOOL state;for (int i = 0; i < m_listctl.GetItemCount(); i++) {state = m_listctl.GetCheck(i);if (state == FALSE) {m_listctl.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);m_listctl.SetCheck(i, TRUE);}else {m_listctl.SetItemState(i, ~LVIS_SELECTED, LVIS_SELECTED);m_listctl.SetCheck(i, FALSE);}}