Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dropdown list activation of ComboBox in Grid
Message
From
23/07/2002 13:06:18
Spencer Redfield
Managed Healthcare Northwest, Inc.
Portland, Oregon, United States
 
 
To
19/07/2002 13:24:19
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00507052
Message ID:
00681776
Views:
27
This message has been marked as the solution to the initial question of the thread.
Hi Tracy,

Sorry it took a few days to get back. The following should be just the essense of what I used to permit row navigation in a grid when focus is on a cell whose CurrentControl is a ComboBox.

There is one behavior to note. Here both Alt+DnArrow and F3 open and display the my ComboBox's contents. If opened by "F3" the user can then use Up and Dn arrows to navigate among the dropdown items. Unfortunately if opened by Alt+DnArrow, Up and Dn arrows instead change the row. I have not taken the time to solve this issue but would be interested if you have any insight.

I should mention that my notes indicate that I got significant help from the following thread, 05/10/2001 18:43:48 Marcia Akins thread #014135.

Anyway, here is the code. I hope it is of some help.

Spencer
*** GotFocus
* Handle the ComboBox class's normal stuff
dodefault()
with this
	* Whether the drop down list is expanded and visible
	.ListExpanded = .F.
endwith
*********************************

*** Init
with this
	* Handle the ComboBox class's normal stuff
	dodefault()
	* Keeps track of whether the dropdown list has dropped down & is visible
	.AddProperty( "ListExpanded ", .F. )
	* The default value of 	ON( "KEY", "F3" ) outside of this control
	.AddProperty( "cWasOnKey_F3", "" )
	* The maximum number of rows in this grid
	.AddProperty( "GridMaxRows", ;
					int( ( .Parent.Parent.Height - .Parent.Parent.HeaderHeight - ;
					iif( inlist( .Parent.Parent.ScrollBars, 1, 3), sysmetric(8), 0 ) ) ;
					/ .Parent.Parent.RowHeight ) )
endwith		&& this
*******************************

*** KeyPress
lparameters nKeyCode, nShiftAltCtrl

#INCLUDE	InkeyValues.h	&& Values from VFP's help for function INKEY()

local	loGrid
with this
	loGrid = .Parent.Parent
	do case
	case ( nKeyCode == KEY_F3_ALONE ) AND ( nShiftAltCtrl == NONE_PRESSED )
		* F3 = Opens Combo box
		* We override the application's normal ON KEY LABEL "F3" action just while in this Combobox.
		* The application's normal ON KEY LABLE "F3" is deactivated in this object's 
		* GotFocus and reactivated in LostFocus. 
		nodefault
		if ( ! .ListExpanded )
			.ListExpanded = .T.
			keyboard "{Alt+DnArrow}"
		endif
	case ( ! .ListExpanded )	&& DropDown list is  *NOT*  displayed
		do case
		case ( ( nShiftAltCtrl == 4 ) AND ( nKeyCode == KEY_DOWN_ARROW_ALONE ) )
			* "{Alt+DnArrow}"  ---  Opens Combo box
			.ListExpanded = .T.

		case ( ( nShiftAltCtrl == NONE_PRESSED ) AND ;
		( inlist( nKeyCode, KEY_DOWN_ARROW_ALONE, KEY_UP_ARROW_ALONE ) ) )
			nodefault
			.ListExpanded = .F.

			* - - - - - - - - - - - - - - -
			select ( loGrid.RecordSource )
			* - - - - - - - - - - - - - - -

			* DOWN Arrow grid navigation
			if ( ( nKeyCode == KEY_DOWN_ARROW_ALONE ) AND	( nShiftAltCtrl == NONE_PRESSED ) )
				if ( ! eof() )
					skip
					if ( eof() )
						go bottom
					endif
				endif
			endif
			* UP Arrow grid navigation
			if ( ( nKeyCode == KEY_UP_ARROW_ALONE ) AND ( nShiftAltCtrl == NONE_PRESSED ) )
				if ( ! bof() )
					skip -1
					if ( bof() )
						locate
					endif
				endif
			endif
		endcase
	otherwise
		* The Drop Down list is currently displayed
		if ( inlist( nKeyCode, KEY_ENTER_ALONE, KEY_TAB_ALONE ) )
			.ListExpanded = .F.
		endif
	endcase
endwith		&& this
*********************************

*** LostFocus
local	lcMacro
lcMacro = this.cWasOnKey_F3
on key label "F3"  &lcMacro.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform