Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo Box and DownArrow Logic
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00827289
Message ID:
00827302
Vues:
22
Hi Jim.

Is there logic to detect whether someone has opened up the list and if so, I could then default to the combobox up/down arrow behaviour. If closed, then it goes up and down in the grid.

Add a logical flag to your combo class and call it lDroppedDown. Set it to .T. in the DropDown() method and to .F. in the Click(). Add a Custom method to the combo called HandleKey() and call it from the KeyPress(). This code in HandleKey():
LPARAMETERS nKeyCode
LOCAL lnMaxRow, 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 the maximum number of rows in the grid
      lnMaxRows = INT( ( .Height - .HeaderHeight - ;
			IIF( INLIST( .ScrollBars, 1, 3 ),;
  			     SYSMETRIC( 8 ), 0 ) ) / .RowHeight )
      *** Move up a row in the grid: up arrow key pressed
      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 )		            
        ENDIF   
        .ActivateCell( .RelativeRow - 1, .ActiveColumn )
        *** Let KeyPress know we have handled the keystroke
        llRetVal = .T.
      ELSE
        *** Move down a row in the grid if the down arrow key is pressed and the
        *** combo box is closed
        *** 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, .ActiveColumn )
	  llRetVal = .T.
        ENDIF
      ENDIF
    ENDWITH
  ENDIF
ENDWITH

RETURN llRetVal
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform