Microsoft KB Archive/189505

= FIX: Init Event Code to Multilselect List Box Items Fails =

Article ID: 189505

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q189505



SYMPTOMS
When you use code in the Init event of a form to multi-select items in a list box, the items are not correctly selected.

This behavior does not occur in Visual FoxPro version 3.0x.



CAUSE
This is a timing problem in Visual FoxPro 5.x.



RESOLUTION
To obtain the proper behavior, you can use a Timer object to control the code that you multi-select.

Steps to Use a Timer Object
 Create a form with a list box object and name the list box List1.  In the Init event of the form, add the following code: THIS.Timer1.ENABLED = .T.                    Add a Timer control to the form and name it Timer1. Set the Interval property to 50.  Add the following code to the Timer event of Timer1: THISFORM.List1.ADDITEM("Red") THISFORM.List1.ADDITEM("Green") THISFORM.List1.ADDITEM("Blue") THISFORM.List1.MULTISELECT = .T.     THISFORM.List1.SELECTED(2) = .T.      THISFORM.List1.SELECTED( 3 ) = .T.      THIS.INTERVAL = 0 THIS.ENABLED = .F.                    Run the form and note that both the second and third items are properly selected.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual FoxPro 6.0.

<div class="moreinformation_section">

Steps to Reproduce Behavior
 Create a form with a list box object and name the list box List1.</li>  In the Init event of the form add the following code: THIS.list1.ADDITEM('red') THIS.list1.ADDITEM('green') THIS.list1.ADDITEM('blue') THIS.list1.MULTISELECT=.T.     THIS.list1.SELECTED(2)=.T.      THIS.list1.SELECTED(3)=.T.                    </li> Close and then run the form. Note that the third item has a dotted line around it and the second item is not selected when both items should be selected.</li></ol>

Keywords: kbbug kbfix kbvfp600fix kbxbase KB189505

-

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

© Microsoft Corporation. All rights reserved.