/*
D:Visual_Studio_reposMFC6
*/
m_list.ModifyStyle(LVS_TYPEMASK, LVS_REPORT);
m_list.InsertColumn(0, _T("这是第一列"), LVCFMT_LEFT, 120);
m_list.InsertColumn(0, _T("这是第二列"), LVCFMT_LEFT, 120);
cImageLarge.Create(IDB_BITMAP1, 32, 1, RGB(255, 0, 255));
cImageSmall.Create(IDB_BITMAP2, 16, 1, RGB(255, 0, 255));
m_list.SetImageList(&cImageLarge, LVSIL_NORMAL);
m_list.SetImageList(&cImageSmall, LVSIL_SMALL);
void CMy6Dlg::OnBnClickedButton1()
{
CString mString;
int count;
count = m_list.GetItemCount();
mString.Format(_T("第%d行 第一列"), count + 1);
m_list.InsertItem(count, mString);
mString.Format(_T("第%d行 第二列"), count + 1);
m_list.SetItemText(count ,1, mString);
}
void CMy6Dlg::OnBnClickedButton2()
{
int count;
count = m_list.GetItemCount();
for (int i = count; i > 0; i--) {
if (m_list.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED) {
m_list.DeleteItem(i);
}
}
}
void CMy6Dlg::OnCbnSelchangeCombo1()
{
CComboBox *cb = (CComboBox *)GetDlgItem(IDC_COMBO1);
int getSelectNum = cb->GetCurSel();
switch (getSelectNum)
{
case 1:
getSelectNum = LVS_ICON;
break;
case 2:
getSelectNum = LVS_SMALLICON;
break;
case 3:
getSelectNum = LVS_REPORT;
break;
case 4:
getSelectNum = LVS_LIST;
break;
default:
break;
}
m_list.ModifyStyle(LVS_TYPEMASK, getSelectNum);
}