fmoore1111
Programmer
I found some neat code in this forum to create a combo box subclass that I need. However, for life of me cannot figure how to change this PRG file to a VFP VCX file- never done it before. Any suggustions what I need to do?
Code:
**************************************************
*-- Class: cbonotinlist
*-- ParentClass: combobox
*-- 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