Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox in Grid - Up/DownArrow ?
Message
From
23/12/2002 21:42:56
 
 
To
23/12/2002 06:19:49
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00735270
Message ID:
00735565
Views:
9
Hi Marcia,
Well I'm having a problems with this. Hopefully you can tell me what I did wrong.

It works pretty good except when I hit {Enter} while it's dropped down. Then it goes back into the Click() method and sets lDroppedDown=.T. again even though it is not dropped down, so up/down don't change rows in the grid. If I hit {Enter} while it's not dropped down, then it resets it back correctly and continues fine.

I just figured it out. In the Click() event I should have "lDroppedDown=.F." not "=.T.". Seems to be working fine now.

Thanks again.


>Hello Bill.
>
>If I put a ComboBox in a Grid, is there any way to use the keyboard to move up or down in the column? I have a grid where all but 1 column uses a ComboBox as the CurrentControl and it's a pain using the mouse to move up one cell.
>
>I assume, then, that this is a drop down list because when you put a drop down combo (style=0) in a grid, the cursor keys behave as you would expect them to.
>
>All you need to do is to add a property to your combo class called lDroppedDown and set it appropriately when the list is droppped ( in the click and the DropDown events ). Add this method ( called handleKey ) to your combo class and call it from the combo's KeyPress:
>
>
>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
>
Bill Morris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform