Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drop Down Combo won't show controlsource
Message
De
27/08/1998 04:09:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00130375
Message ID:
00130398
Vues:
18
>I'm always confused by the combos. I was using a drop down list in a grid and it was working great showing me the field in the table, yet allowing the user to choose items from an array list. Now I've decided I want the users to have the option to enter a value not from the list, so I changed the style to a drop down combo and I can no longer see the field values - it's just blank on every row. The controlsource still says the field name, the column's Sparse value is false, what am I missing?
Diana,
Try this class :
DEFINE CLASS cmbself_edit AS combobox

  Height = 22
  Width = 100
  DisabledBackColor = RGB(255,255,255)
  aliasname = "None"
  fieldname = "None"
  Name = "cmbself_edit"

  PROCEDURE GotFocus
    this.REQUERY				&& Do we have new elements ?
    this.value = eval(this.controlsource)	&& Reposition
  ENDPROC

  PROCEDURE InteractiveChange
    *
    * Self note : Restudy this code
    *
    *This.displayvalue = ;
    * Chrtran(This.displayvalue,"yi","IY") && Local language fix
    WITH this
      IF .selstart = 0
        RETURN
      ENDIF
      cPos = .selstart
      IF lastkey() = 127 && Backspace
        IF .selstart = 1
          .displayvalue = ""
          .selstart = 0
          .sellength = 0
          RETURN
        ENDIF
        cCheckValue = left(.displayvalue,.selstart-1)
        cPos = cPos - 1
      ELSE
        cCheckValue = iif(cPos = 1,"",left(.displayvalue,cPos-1))+chr(lastkey())
      ENDIF
      lExistsOne = .f.
      FOR ix = 1 to .listcount
        IF  Upper(Alltrim(.list(ix))) = upper(alltrim(cCheckValue))
          .displayvalue = .list(ix)
          lExistsOne = .t.
          EXIT
        ENDIF
      ENDFOR
      .selstart = cPos
      IF lExistsOne         && Available item
        .sellength = len(.displayvalue) - cPos
      ELSE
        .sellength = 0
      ENDIF
    ENDWITH
  ENDPROC

  PROCEDURE LostFocus
    *This.displayvalue = ;
    * Chrtran(This.displayvalue,"yi","IY") && Local language fix
    this.value = this.displayvalue
    this.displayvalue = this.value
  ENDPROC

  PROCEDURE Init
    WITH This
      .rowsourcetype = 3
      IF lower(.fieldname)="none" or ;
          lower(.aliasname)="none"	&& Lookup is same as controlsource alias
        .fieldname = substr(.controlsource,rat(".",.controlsource)+1)
        .aliasname = substr(.controlsource,1,;
          rat(".",.controlsource)-1)
      ENDIF
      .rowsource = [SELECT DISTINCT ]+THIS.fieldname +;
        [ as dummy FROM ]+this.aliasname+[ where !empty(]+THIS.fieldname + ;
        [) union ] +;
        [SELECT this.displayvalue as dummy ] +;
        [ FROM ]+this.aliasname + ;
        [ union ] +;
        [SELECT this.value as dummy ] +;
        [ FROM ]+this.aliasname + ;
        [ INTO cursor qq order by 1 ]
      IF .parent.baseclass = "Column"
        .parent.sparse = .t.  && Force sparse .t. for grids
      ENDIF
    ENDWITH
  ENDPROC

ENDDEFINE
You can drop interactivechange. Sparse setting was always a problem so I forced it to be .t. You could implement this to rowsourcetype = Array also. Hope helps.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform