Microsoft KB Archive/156737

= BUG: Disabled ListBox items can be accessed by using the keyboard in Visual FoxPro for Windows =

Article ID: 156737

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 9.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Professional Edition
 * Microsoft Visual FoxPro 3.0 Professional Edition

-



This article was previously published under Q156737



SYMPTOMS
An item in a ListBox control can be disabled by placing a backslash (\) before the item. The item appears disabled and cannot be selected by using the mouse. The item can still be accessed by using the keyboard.



WORKAROUND
To work around this issue, add items to the ListBox control by using the AddItem method. Put both a backslash (\) and a closing bracket (]) in front of the items. However, this workaround applies only to items that are added by using the AddItem method.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.



Steps to reproduce the behavior

 * 1) Open Visual FoxPro and create a new program.
 * 2) Paste the code below into the program.
 * 3) Save and run the program.
 * 4) When the form appears, try to select disabled items in the list by using the mouse and keyboard. You should find that you cannot select disabled items with the mouse (which is the desired behavior), but you can select them with the keyboard (the bug).
 * 5) To see the AddItem workaround, close the form and edit the program.
 * 6) Uncomment out the first line of code ( *#DEFINE UseAddItem ) and run the program again. This time you should be unable to select disabled items in the list with either the mouse or keyboard.

*#DEFINE UseAddItem

LOCAL i PUBLIC oForm oForm = NEWOBJECT('Form')

WITH oForm .ADDOBJECT([LST], [ListBox]) .LST.VISIBLE = .T.

#IFDEF UseAddItem

*-- Add items to the list, and *-- disable some of them. FOR i = 1 TO 9 .LST.ADDITEM(              IIF(MOD(9, i) = 0, ; '\]' + SYS(2015), ; SYS(2015))) ENDFOR

#ELSE

.ADDPROPERTY('aMyArray[9]') FOR i = 1 TO 9 STORE IIF(MOD(9, i) = 0, ;               '\' + SYS(2015), ;                SYS(2015) ) TO oForm.aMyArray[i] ENDFOR .LST.ROWSOURCE = [THISFORM.aMyArray] .LST.ROWSOURCETYPE = 5 &&Array

#ENDIF

.SHOW ENDWITH

Additional query words: kbvfp300 kbvfp300b kbvfp500 kbvfp500a kbvfp600

Keywords: kbcodesnippet kboop kbctrl kbbug KB156737

-

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

© Microsoft Corporation. All rights reserved.