Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown cbolist

Status
Not open for further replies.

mccartmd

Programmer
Feb 3, 2003
63
US
Hi, I have a combo box a grid column.
Is there a way to prevent the drop down of the combo list
till a person double clicks it as vs when you click on it
picking a record in the grid it automatically drops down.

M
 
This is code from another forum by Spencer Redfield

Code:
*** 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.

I haven't tested it.
 
Thank you, star for you and give one to Spencer too
M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top