Microsoft KB Archive/134245

= FIX: Multi-Select List Box Does Not Retain Selected Items =

Article ID: 134245

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q134245



SYMPTOMS
A List Box that has the Multi-Select property set to True does not always retain the selected items.



WORKAROUND
Listed below are two workarounds:


 * Create a mover-type list box to move the items from one list to another.

-or-
 * Populate the list box using the AddItem method, and set the RowSourceType to None, instead of basing the list box on fields.

For more information about the behavior of list boxes when set to None, please see the following article in the Microsoft Knowledge Base:

136588 PRB: List Boxes and Combo Boxes Lose Item Properties

Steps Populate the List Box Using AddItem Method
The following steps can be used to fix the sample listed later in this article, under the "Steps to Reproduce Problem" section, assuming that the customer table from Testdata.dbc has first been added to the data environment.

  Change the following properties of the list box: RowSourceType=none - 1 RowSource=(empty)   Place the following in the Init Method of the list box: SCAN THIS.ADDITEM(cust_id, RECNO, 1) THIS.LIST(RECNO, 2)=address ENDSCAN   In the RightClick Method of the list box add the following: FOR i= 1 to THIS.LISTCOUNT IF THIS.SELECTED(i) ? THIS.LIST(i) ENDIF ENDFOR 



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0 for Windows.



Steps to Reproduce Problem
 Create a form, and place a list box on it.  Set the list box properties as follows: ColumnCount = 2 ColumnWidths=50,200 Multi-Select = .T.  RowSource=customer.customer_id,address RowSourceType=6-Fields </li> Run the form, and select the first item. Hold down the SHIFT key, and use the elevator bar to go to the bottom of the list and select the last item.</li> Scroll from the bottom of the list to the top to verify that all of the items are still selected. You will see that some of the items are no longer selected. The items that are no longer selected are not always the same items; they may vary from trial to trial.</li></ol>

Additional query words: multiselect

Keywords: kbbug kbfix kbvfp500fix KB134245

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.