DOCUMENT:Q156035 14-DEC-1999 [foxpro] TITLE :PRB: Control in Grid w/ When Returning .F. Passes Keys to Form PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:3.0,3.0b,5.0,6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== Clicking on a grid column whose control's When() returns False allows focus to be set to the grid column. In this state, keystrokes are passed to the form containing the grid, calling the form's KeyPress event and actuating any hotkeys on controls on the form. WORKAROUND ========== - Do not return False (.F.) from the control's When(), and conditionally issue a KEYBOARD "{tab}" command in the control's GotFocus() to keep focus off column. - or - - Conditionally issue a NODEFAULT in the KeyPress() method of the form. STATUS ====== This behavior is by design. MORE INFORMATION ================ This is normal behavior for the Grid object. This situation occurs because the Grid object must change the record pointer before it can query columns or column controls for Enabled = True. Once the record pointer is changed, the grid can't go back because the grid does not save a previous record pointer. Leaving the focus on the prior column before the user switches to the disabled column or control may lead to problems when handling two special cases: - When the grid is entered for the first time and there is no prior column. - When DynamicCurrentControl is used and the current control for the previous column gets set to a disabled control. In addition, the grid must behave this way to accommodate the following special case: - If all the columns of a grid are disabled and the RecordMark and DeleteMark properties are set to False, the user needs to have a way to change the record pointer within the grid. For more information about selection of grid columns with disabled controls, or controls whose When() returns False, please see the following article in the Microsoft Knowledge Base: Q137963 PRB: Disabled Grid Controls Can Be Selected with Mouse Steps to Reproduce Behavior --------------------------- 1. Run the following code from a program file: * Start of sample program PUBLIC oForm oForm=CREATEOBJECT('form1') oForm.SHOW oForm.grid1.column1.ADDOBJECT('text2','txtTextbox') oForm.grid1.column1.CURRENTCONTROL='text2' oForm.grid1.column1.text2.VISIBLE=.T. DEFINE CLASS form1 AS FORM ADD OBJECT grid1 AS GRID WITH ; COLUMNCOUNT = 2, ; NAME = "Grid1" ADD OBJECT command1 AS COMMANDBUTTON WITH ; CAPTION = "\