PRB: Clicking a Disabled Item in a List Box Selects ItID: Q131300 3.00 WINDOWS
The information in this article applies to:
SYMPTOMSOne or several items in a list box are disabled. If a disabled element is clicked and then enabled, it becomes the selected item in the list.
CAUSEThe value property of the combo box determines which item is displayed. This property is modified when you scroll through a list and the LISTINDEX property varies. Clicking any item in a list, even if it is disabled, changes the LISTINDEX property. If the element is then enabled, the LISTINDEX property is still set to this item, and the list box value is set to the value of the element.
WORKAROUNDAn alternative is to compare the elements referred by the LISTINDEX and the VALUE properties. If the VALUE property of the combo box is different from the value of the element referred by LISTINDEX, reset the listindex property to the value property. You can then enable the list element.
STATUSThis behavior is by design.
MORE INFORMATIONThe following example program illustrates a workaround to the behavior described. It displays a form with a combo box and a command button. The command button enables all of the items in the list. When the button is clicked, the program checks if the value of the combo box corresponds to the listindex. If it does not, the listindex is reset. To run this sample program, copy and paste the code into a program file (.PRG file), and run it. When the list is displayed, click the third element, which is disabled. Then click the command button. The element displayed in the text part of the combo box does not change.
Example Workaround CodeoForm1=CREATE('myform') oForm1.SHOW *:************************************************************************* *: *: Class: myform BaseClass: FORM *: *:************************************************************************* DEFINE CLASS myform AS FORM Additional reference words: 3.00 VFoxWin
KBCategory: kbprb
KBSubcategory: FxprgGeneral
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |