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



The information in this article applies to:

  • Microsoft Visual FoxPro 9.0 Professional Edition
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows, Professional Edition 3.0b
  • Microsoft Visual FoxPro for Windows, Professional Edition 3.0

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.

MORE INFORMATION

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


Modification Type:MinorLast Reviewed:2/7/2005
Keywords:kbCodeSnippet kbOOP kbCtrl kbBug KB156737