unselect all in list box

Started by Shawn Anderson, November 15, 2009, 06:24:46 PM

Previous topic - Next topic

Shawn Anderson

I have a multiple-select listbox that I want to clear all the selections in.

I'm using:

FF_ListBox_SetCurSel( HWND_FORM1_LIST1, -1 )

but it doesn't unselect anything?



Shawn Anderson

after some more testing, I see that it works for a single select box, but not for multiple select.

I tried to read the contents of the listbox and unselect them one at a time, but that didn't work either.

Suggestions?


Paul Squires

If you look at the source for the FF_ListBox_SetCurSel you will see that it calls the ListBox using the %LB_SETCURSEL message. Looking up that message in the api help it says.....


Use this message only with single-selection list boxes. You cannot use it to set or remove a selection in a multiple-selection list box.


When dealing with multiple selection listboxes, you use the %LB_SETSEL message to select or deselect items. The following code deselects all lines in the listbox.


   Local NumItems As Long
   Local y        As Long

   NumItems = FF_ListBox_GetCount( HWND_FORM1_LIST1 )
   
   For y = 0 To NumItems - 1
      SendMessage HWND_FORM1_LIST1, %LB_SETSEL, %FALSE, -1
   Next


Paul Squires
PlanetSquires Software

Shawn Anderson