listctrl删除多行

1.响应WM_KEYDOWN事件。

2.删除一行,item的序号自动调整了。

void CDlg::OnKeydownListFile(NMHDR* pNMHDR, LRESULT* pResult) { LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR; // TODO: Add your control notification handler code here int i=0; int n = 0; int to_delete[65535]; if (pLVKeyDow->wVKey == VK_DELETE) { POSITION pos = m_list.GetFirstSelectedItemPosition(); if(pos==NULL) { TRACE0("No items were selected!/n"); } else { while(pos) { to_delete[i++] = m_list.GetNextSelectedItem(pos); } } n=m_list.GetSelectedCount();//被选择总数; int k = 0; for(i = 0; i < n; i++) { m_list.DeleteItem(to_delete[i]-k);//依依删除; k++; } } *pResult = 0; }

你可能感兴趣的:(null,delete)