PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Shawn Anderson on November 15, 2009, 06:24:46 PM

Title: unselect all in list box
Post by: Shawn Anderson on November 15, 2009, 06:24:46 PM
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?


Title: Re: unselect all in list box
Post by: Shawn Anderson on November 15, 2009, 06:44:25 PM
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?

Title: Re: unselect all in list box
Post by: Paul Squires on November 15, 2009, 06:48:04 PM
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


Title: Re: unselect all in list box
Post by: Shawn Anderson on November 16, 2009, 08:13:12 PM
thanks