• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 830
  • Last Modified:

CListBox Unselect ??

When you have a CListBox and have selected an item then you cant unselect this item by for example clicking in the CListBox but not on an item....
I would like to be able to unselect items...

How do I solve this problem ?? Is there a message.. ?
0
TYB
Asked:
TYB
  • 2
  • 2
1 Solution
 
gvgCommented:
Hi.

There are 2 functions in CListBox that you can use.

SetCurSel( int nSelect );

Whice is used if you have a single select listbox.  Passing -1 will deselect all.

If you have a multiple select listbox use

SetSel( int nIndex, BOOL bSelect = TRUE );

where

nIndex

Contains the zero-based index of the string to be set. If –1, the selection is added to or removed from all strings, depending on the value of bSelect.

bSelect

Specifies how to set the selection. If bSelect is TRUE, the string is selected and highlighted; if FALSE, the highlight is removed and the string is no longer selected. The specified string is selected and highlighted by default.

Gunnar Valur
0
 
TYBAuthor Commented:
Ok... but how do I know when to deselect all items ? I don´t always wanna deselect them....
'
0
 
gvgCommented:
You might for example trap the mouse click message and make it so that once someone clicks an item and it is selected it will be deselected.
0
 
TYBAuthor Commented:
Ok... tnx a lot for the help...

Btw... Happy New Millenium... : )
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now