BUG: Using Selected Method in Init Event Does Not Work

Last reviewed: December 4, 1997
Article ID: Q177340
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a

SYMPTOMS

In Visual FoxPro versions 5.x, programmatically using the Selected method to select an item in a list box does not work in the Init method of a list box or a form.

RESOLUTION

Use the following method to programmatically select an item in the Init method of a list box or a form:

   Thisform.List1.DisplayValue = Thisform.List1.List(1) && This will select
                                                        && the first item.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

This problem does not occur in Visual FoxPro versions 3.x.

Steps to Reproduce Behavior

  1. Create a form and named it MyList.

  2. Place a list box object on the form and set the following properties:

          RowSourceType  = 1 - Value
          RowSource = "One, Two, Three, Four, Five" (without the quotations)
    

  3. In the Init method of the form, type the following code:

          Thisform.List1.Selected(1)=.T. && Select the first item.
    

  4. Save and run the form.

    NOTE: When the form runs, no item is selected in the list box.


Additional query words: Listbox Selected
Keywords : FxprgClassoop vfoxwin
Version : WINDOWS:5.0,5.0a
Platform : WINDOWS
Issue type : kbbug


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: December 4, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.