Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created one list control box in MFC. I have clicked on Row and that Row is selected.Now If I click anywhere outside of this list control box on that dialogue, that Row should be deselected. I have gone through but not able to find any help or solution, please help me out, As I am new to MFC.
Thanks
Posted
Comments
Philippe Mori 24-Aug-13 9:45am    
This is not an expected behavior so it might confuse tour users. Best to provide an unselect button for that purpose, or add an item "no selection" to the list or if the user click on the list but not an item deselect it or use extended selection mode in which Ctrl+Click can be used to select or unselect items (multiple sélections including none).

1 solution

Use the CListBox::SetCurSel[^] function to clear the selection, probably in the OnKillFocus[^] override.
 
Share this answer
 
Comments
CPallini 23-Aug-13 3:58am    
5.
Richard MacCutchan 23-Aug-13 4:06am    
Thanks. Yet another question that could be answered simply by reading the documentation.
CPallini 23-Aug-13 4:10am    
Yes, sometimes the 'router to the right documentation page' is boring.
H.Brydon 25-Aug-13 22:16pm    
+5 for the answer, but in defense of OP, the answer to this question is not easily findable unless you know the answer already.
Richard MacCutchan 26-Aug-13 2:35am    
I didn't know it already, I read the documentation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900