Activating multiple items in a wxListCtrl?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Luke727
Earned some good credits
Earned some good credits
Posts: 130
Joined: Wed Dec 22, 2004 9:31 am

Activating multiple items in a wxListCtrl?

Post by Luke727 » Wed May 04, 2005 10:12 pm

Is there a straightforward way to active multiple items in a wxListCtrl? The EVT_LIST_ITEM_ACTIVATED macro only handles a single item (as far as I can tell). The only way I can think of to do this is the following:

1. Handle the ITEM_SELECTED and ITEM_DESELECTED events.
2. Keep a list of the currently selected items (added on ITEM_SELECTED, removed on ITEM_DESELECTED).
3. In ITEM_ACTIVATED, use the list of selected items as my parameters instead of event.GetIndex().

Is this the best approach, or is there something I am missing?

Obviously this will only work for the enter key or a menu item / button, as double clicking will select one item and then activate it.

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Thu May 05, 2005 6:30 am

First, the style must not have wxLC_SINGLE_SEL.
Second, if I understand correctly, your can use GetSelectedItemCount() and GetNextItem() with correct params.

wxListCtrl::GetNextItem (with an example) : http://www.wxwidgets.org/manuals/2.6.0/ ... etnextitem
What is little and green, witch go up and down ??
Yoda playing with the force.

Post Reply