// Find the selection long wxListCtrlGetSelection(wxListCtrl& listCtrl) { long n = listCtrl.GetItemCount(); long i; for (i = 0; i < n; i++) { if (listCtrl.GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED) { return i; } } return -1; }
// Select the given item void wxListCtrlSelectItem(wxListCtrl& listCtrl, long sel, bool deselectOthers) { long n = listCtrl.GetItemCount(); long i; if (deselectOthers) { for (i = 0; i < n; i++) { if (listCtrl.GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED) { listCtrl.SetItemState(i, wxLIST_STATE_SELECTED, 0); } } } listCtrl.SetItemState(sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); }