CListCtrl - How to prevent an item from being deselected when user clicks elsewhere on the listbox?
Posted on 2004-09-14
I have a CListCtrl object (listbox). I understand that to make an item selected/highlighted, I can use SetItemState(nItem, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED). Subsequently, the selection/focus will follow according to the item that user has click.
But once the user clicks on elsewhere on the listbox (not on any item), the item gets deselected. How can I prevent the listbox from getting deselection? My listbox should always have one item selected. And if the user clicks elsewhere on the listbox, the item that is currently selected should not be deselected and shld stay selected/highlighted.
Experts, pls advise!