Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox Value when user input is allowed not showing
Message
From
10/10/2006 06:53:03
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01160690
Message ID:
01160787
Views:
10
When I have the combobox in style 0 (Dropdown Combo mode) and the user enters data that is not in the dropdown list, it seems to not update the control source variable. I can manually update it with m.XXX=this.text and it will save the text, but when I recall the record, the combobox is empty even though the control source variable has the user data. Is there a trick to get the combobox to display the text from the control source variable when it is not in the dropdown list?
*-- 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
Previous
Reply
Map
View

Click here to load this message in the networking platform