X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/614391dc087ca70b145e07c442815217f8aa3162..a95cdab85c5e5abb2d40e594663f120db3675bb4:/samples/listctrl/listtest.cpp diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index 91341cae92..d1c8d7d4af 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -681,9 +681,20 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event) break; case WXK_DELETE: - DeleteItem(event.GetIndex()); + { + long item = GetNextItem(-1, + wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + while ( item != -1 ) + { + DeleteItem(item); + + wxLogMessage(_T("Item %ld deleted"), item); - wxLogMessage(_T("Item %d deleted"), event.GetIndex()); + // -1 because the indices were shifted by DeleteItem() + item = GetNextItem(item - 1, + wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + } + } break; case WXK_INSERT: