************************************************** *-- Class: cbonotinlist *-- ParentClass: cboqfill *-- BaseClass: combobox *-- Time Stamp: 12/12/99 06:38:09 PM *-- ALLOWS SELECTION OF AN ITEM NOT IN THE COMBO'S LIST TO BE USED AS ITS CONTROLSOURCE...ONLY WORKS IF THE COMBO'S BOUND COLUMN IS 1 * Define Class cbonotinlist As cboqfill *-- Used to save the control source of the combo before the control is unbound ccontrolsource = "" Name = "cbonotinlist" *-- Called from Valid...it updates the "bound" field Procedure updatecontrolsource Local lcAlias, lcControlSource With This If ! Empty( .ccontrolsource ) lcAlias = Juststem( .ccontrolsource ) If Upper( Alltrim( lcAlias ) ) = 'THISFORM' lcControlSource = .ccontrolsource Store .DisplayValue To &lcControlSource Else Replace ( .ccontrolsource ) With .DisplayValue In ( lcAlias ) Endif Endif Endwith Endproc *-- Updates display value from the field in the underlying table if this is a "bound" control Procedure refreshdisplayvalue Local lcControlSource With This If ! Empty( .ccontrolsource ) lcControlSource = .ccontrolsource .DisplayValue = &lcControlSource Endif Endwith Endproc Procedure Init If DoDefault() With This .ccontrolsource = .ControlSource .ControlSource = '' Endwith Endif Endproc Procedure Valid This.updatecontrolsource() Endproc Procedure Refresh This.refreshdisplayvalue() Endproc Procedure GotFocus If Lower( This.Parent.BaseClass ) = 'column' *** This is needed so it will work in a grid ComboBox::GotFocus() This.refreshdisplayvalue() Nodefault Else DoDefault() Endif Endproc Enddefine * *-- EndDefine: cbonotinlist **************************************************
************************************************** *-- Class: cboqfill *-- ParentClass: combobox *-- BaseClass: combobox *-- Time Stamp: 02/02/06 03:18:04 PM * Define Class cboqfill As cbobase SelectOnEntry = .T. Style = 0 coldexact = "" Name = "cboqfill" Procedure handlekey Local lcSofar, lnSelStart, lnSelLength, lnRow With This *** Handle backspace key If Lastkey() = 127 .SelStart = .SelStart - 1 Endif *** Get the value typed in so far lnSelStart = .SelStart lcSofar = Left( .DisplayValue, lnSelStart ) *** Find a match in column #1 of the combo's internal list For lnRow = 1 To .ListCount If Upper( .List[ lnRow, 1 ] ) = Upper( lcSofar ) .ListIndex = lnRow Exit Endif Endfor *** Highlight the portion of the value after the insertion point .SelStart = lnSelStart lnSelLength = Len( Alltrim( .DisplayValue ) ) - lnSelStart If lnSelLength > 0 .SelLength = lnSelLength Endif Endwith Endproc Procedure LostFocus If This.coldexact = 'ON' Set Exact On Endif Endproc Procedure GotFocus With This .uOldVal = .Value ComboBox::GotFocus() This.SelStart = 0 This.SelLength = Len( This.Text ) .coldexact = Set( 'EXACT' ) Set Exact Off Nodefault Endwith Endproc Procedure InteractiveChange *** handle the key...IOW, find the closest match in the list If This.SelStart > 0 If ( Lastkey() > 31 And Lastkey() < 128 ) Or ( Lastkey() = 7 ) This.handlekey() Endif Endif Endproc Enddefine * *-- EndDefine: cboqfill **************************************************