PRB: List Boxes and Combo Boxes Lose Item Properties

Last reviewed: August 6, 1997
Article ID: Q136588
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0

SYMPTOMS

When the RowSource property of a ComboBox or ListBox control is set to a value other than 0-None and there are many items in the list, properties of individual items are lost when you scroll down the list. For example, if you select several items from the list, scroll down the list, and then scroll up the list, the selected items might not be highlighted anymore.

CAUSE

This behavior is due to architectural limitations in the manager that handles the lists. When the RowSource is non-zero, the list manager creates 60 items internally and recycles them. This improves performance for lists that have a large number of items. For example, if a list is populated with a million-row table, Visual FoxPro does not have to take the speed and memory penalty associated with creating a million list items. Because they are recycled, properties set on the items are lost during operations such as scrolling. This behavior does not occur in Visual FoxPro 5.0.

RESOLUTION

Populate the controls with the AddItem and RemoveItem methods. These methods create non-recyclable items that are guaranteed to retain their properties.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Place a ListBox control on a form.

  2. Save and run the form.

  3. Type the following in a program, and run the program:

    Listbox.RowSourceType = 6 *** type fields Listbox.RowSource = "customer.name" Listbox.MultiSelect = .T. Listbox.Selected(1) = .T. Listbox.Selected(100) = .T.

  4. Query the value of Listbox.Selected(1). It returns false (.F.). If you select the first property manually, then scroll down 100 items and multiple-select (hold the SHIFT key down as you click) the 100th item, and then scroll back up to the top, the selection is gone.


Additional query words: List box
Keywords : FxprgClassoop vfoxwin
Version : 3.0 5.0
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.