Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Keyboarding down a grid column that has a combobox
Message
De
05/01/2000 03:56:00
 
 
À
04/01/2000 14:18:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00312626
Message ID:
00313084
Vues:
42
Hi Deri.

>> I have a grid with 2 columns - the first is readonly, the second contains a combobox that is enabled for user entry. I want the user to be able to use the keyboard to enter the value in the combobox, then move down to the next row by hitting tab or enter or down arrow. <<

This code in the combo's KeyPress:
IF This.HandleKey( nKeyCode )
  NODEFAULT
ENDIF	
This code in HandleKey:
LPARAMETERS nKeyCode
LOCAL lnMaxRows, llRetVal

WITH This
  *** If escape or enter pressed, the list is not dropped down anymore
  IF nKeyCode = 27 OR nKeyCode = 13		    
     .lDroppedDown = .F.
  ENDIF
  *** If the list is not dropped down, traverse the grid with cursor keys
  IF !.lDroppedDown
     WITH .Parent.Parent
     
     *** Calculate max # of rows in grid
     lnMaxRows = INT( ( .height - .HeaderHeight - IIF( INLIST( .ScrollBars, 1, 3 ), SYSMETRIC( 8 ), 0 ) ) / .RowHeight )
     *** Move up a row in the grid
     IF nKeyCode = 5 THEN					
        *** If we are sitting on the top row in the visible portion of the grid,
	*** Scroll the grid up a row in case there is a previous record		
	IF .RelativeRow = 1
	   .DoScroll( 0 )		            
	   .ActivateCell( 1, .RelativeColumn )
	ELSE
	   .ActivateCell( lnRelativeRow - 1, .RelativeColumn )
	  ENDIF   
	  *** Let KeyPress know we have handled the keystroke
	  llRetVal = .T.
       ELSE
	  *** If we are sitting on the bottom row in the visible portion of the grid,
	  *** Scroll the grid down a row in case there is a next record			  IF nKeyCode = 24 THEN				
	     IF .RelativeRow > lnMaxRows
	        .DoScroll( 1 )
             ENDIF
	     .ActivateCell( .RelativeRow + 1, .RelativeColumn )
	     llRetVal = .T.
          ENDIF
       ENDIF
     ENDWITH
  ENDIF
ENDWITH

RETURN llRetVal
Obviously, you must set This.lDroppedDown appropriately.

marcia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform