Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox
Message
From
26/10/2006 18:40:29
 
 
To
26/10/2006 08:42:37
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01164676
Message ID:
01164880
Views:
45
This message has been marked as a message which has helped to the initial question of the thread.
can somebody give me a clue how to set the text for a combobox programitcally?

I have the following situation
- A combobox bount to a sql statement (RowSourceType= 3)
- Valid data in sql's result

I like to set the combobox to a value not in the sql result


If you would like a combo box class to do this for you so that you do not need to add code every time you want this functionality, try this class:
**************************************************
*-- Class:        cbonotinlist 
*-- 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 ccombobox

  *-- 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
Next
Reply
Map
View

Click here to load this message in the networking platform