Working with the selection

Once items have been added to a list view, it is often necessary to change the selection or find out which items are selected.

Changing the selection

The user can select items in the list view. You can also use the ListView_SelectionSet() function to change the selection. If the list view field allows multiple items to be selected, use the mode parameter of this function to specify whether an item is being added to or removed from the current selection.

Retrieving the selection

If the list view field allows only one item to be selected, simply use the ListView_SelectionGet() function to return the index of the selected item. If the list view field allows multiple items to be selected, use the ListView_SelectionCount() function to retrieve the number of items selected. Then, using the offset parameter of the ListView_SelectionGet() function, indicate which of the selected items you want to retrieve.

For example, the following illustration shows a list view field that allows multiple selections. The ListView_SelectionCount() function indicates that three items are selected. To retrieve the index for the item “4750 9th Avenue South”, pass the offset value 2 to the ListView_SelectionGet() function to retrieve the second selected item.

[spacer]


Documentation Feedback