How can I clear all selections in a wxListBox which has the style wxLB_MULTIPLE?
Neither wxControlWithItems::SetSelection() nor wxControlWIthItems::SetStringSelection() work.
They only select the passed item but they do not deselect any other items as said in the documentation:
Note that this does not cause any command events to be emitted nor
does it deselect any other items in the controls which support
multiple selections.
Platform independent method
As SteveL mentioned, you have to use
wxListBox::GetSelections()andwxListBox::Deselect()in a loop:ListBox_SetSel macro for Windows systems
You can use the macro ListBox_SetSel from the Windows API.
For this function, you have to include
Windowsx.handwx/msw/winundef.h, of course: