How does the VC List Control control delete a selected record instance
- 2020-05-26 09:44:02
- OfStack
How does the VC List Control control delete a selected record instance
Example code:
OnButtonDelete()
{
POSITION pos = m_list.GetFirstSelectedItemPosition();
int idx = m_list.GetNextSelectedItem(pos);
while (idx != -1){
LVITEM lvi;
lvi.iItem = idx;
lvi.iSubItem = 0;
lvi.mask = LVIF_IMAGE;
if (m_list.GetItem(&lvi)){
m_imgList.Remove(lvi.iImage); // At the same time to delete ImageList The corresponding picture in
}
m_list.DeleteItem(idx);
idx = m_list.GetNextSelectedItem(pos);
}
You need to sort it first and then redraw it, otherwise the area will be blank after it is deleted from the middle, and the subsequent records will not automatically move up
m_list.Arrange(LVA_DEFAULT);
m_list.RedrawItems(0, m_list.GetItemCount());
}
Thank you for reading, I hope to help you, thank you for your support of this site!