Microsoft KB Archive/156549

= FIX: Click Event of a List Box Fires Twice =

Article ID: 156549

Article Last Modified on 10/15/2003

-

APPLIES TO


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

-



This article was previously published under Q156549



SYMPTOMS
In Visual FoxPro 3.0 and 3.0b for Windows, when you click on an item in a list box, the Click event fires and runs the code in the Click event. If the item in the List box is already highlighted and the item is clicked again, the code in the Click event runs twice.



WORKAROUND
If the desired effect is to click on an item and have the Click event fire once and not fire again until another item is chosen, create a form as follows:

 Create a form and place a list box on it. While the list box is highlighted, set the RowSourceType property to Value in the Properties box.  In the RowSource property, type the following values: AAA, BBB, CCC, DDD   In the Click event of the list box, type the following code: WAIT WINDOW "List box, Click event" NOTE: If you run the form at this point, the problem described above occurs.  Modify the form and create a custom property for the form by clicking New Property on the Form menu. In the New Property box type OneClick . In the Init event of the form, type ThisForm.OneClick = X .  In the Click event of the list box change the current code with the following: IF This.DisplayValue != ThisForm.OneClick WAIT WINDOW "List box, Click event" ThisForm.OneClick = This.DisplayValue ENDIF If an item is selected and the Click event needs to be fired regardless of it being previously highlighted, then the code is going to be fired twice. There is no workaround for this case. </li></ol>

<div class="status_section">

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

Keywords: kberrmsg kbbug kbfix kbvfp500fix KB156549

-

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

© Microsoft Corporation. All rights reserved.