FIX: Click Event of a List Box Fires Twice

Last reviewed: February 20, 1997
Article ID: Q156549
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0

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:

  1. Create a form and place a list box on it.

  2. While the list box is highlighted, set the RowSourceType property to Value in the Properties box.

  3. In the RowSource property, type the following values:

          AAA, BBB, CCC, DDD
    

  4. 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.

  5. 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" (without the quotes).

  6. In the Init event of the form, type "ThisForm.OneClick = "X" (without

        the quotes).
    

  7. 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.
    
    

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.


KBCategory: kbprg kbfixlist kberrmsg
KBSubcategory: FxtoolFormdes VFoxWin buglist3.00 buglist3.00b fixlist5.00
Additional reference words: 3.00 3.00b 5.00



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