Rank: Administration
Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor Joined: 23/11/2008(UTC) Posts: 523
|
How to delete selected rows from CListCtrl Code:POSITION pos = pListCtrl->;GetFirstSelectedItemPosition();
while (pos != NULL)
{
int nItem = pListCtrl->GetNextSelectedItem(pos);
pListCtrl->DeleteItem(nItem);
pos = pListCtrl->GetFirstSelectedItemPosition();
}
Delete selected rows with ItemData Code:void OnBtnDelete()
{
if (POSITION pos = pListCtrl->GetFirstSelectedItemPosition()) {
while (pos)
{
int nIndex = pListCtrl->GetNextSelectedItem(pos);
pListCtrl->DeleteItem(nIndex);
pos = pListCtrl->GetFirstSelectedItemPosition();
int dataIndex = 0;
for (auto iter = listCtrlItems.begin(); iter != listCtrlItems.end();)
{
if dataIndex == nIndex)
{
iter = listCtrlItems.erase(iter);
break;
}
else
++iter;
dataIndex++;
}
}
//...
}
}
Edited by user Tuesday, 14 November 2017 9:26:19 PM(UTC)
| Reason: Not specified
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.