Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ComboBox ControlSource
Message
De
20/05/1999 08:43:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/05/1999 15:25:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00220336
Message ID:
00220765
Vues:
29
>Cetin:
>I implemented your suggestion, but I must be missing something. The label displays the contents of the previous record. I've changed directions, and am now trying to get an incremental search on the 2nd column that is the 1-2 character code. I put what was to be in the label caption and put it in column 1. Incremental search works fine but on the wrong data. Any suggestions?
>
>BTW, I had a real tussle with the control source of the combobox. I finally figured out that I need to do the following:
>
>this.value = {value of Fieldname in the view}
>this.controlsource = {fieldname in the view}
>
>When I set the controlsource at design time, the boxes were blank until I went to the next record. If I came back to the 1st record, it now had the correct value. In Debug, I set a watch on COPTA (fieldname) and it was " ", while COPTB (the adjacent field in the view) was "DR" (correct) I've got that all working now, but I'd like to understand why I can't set controlsource at design time.
>
>Thanks for your help!
>Mike
Mike,
A little big miss was in refresh code :
dodefault()
thisform.lblMyLabel.value = this.list(this.listindex,2)
Here I assumed you do incremental search on column 1 but want to display column 2 in label. It might be bound to 1 or 2 (doesn't matter). Using list(listindex,nColumn) provides flexibility in using whatever column order and boundcolumn.
IncrementalSearch and displayvalue works on column1 (this is not from documentation though and I might be wrong - I use combos rarely).
As I get you want to bound to "shortcode" as controlsource and also want to do incrementalsearch on "shortcode". Display "description" (column2) with label.

With combos what I don't like is displayvalue and incrementalsearch are under control of column order and column1 is the owner of those luxuries. Grids that mimic combos has more freedom and flexibility but harder to implement if you don't have one class ready (should be in files\classes section).
Properties of combo :
Rowsourcetype = SQL && My favorite - could be other type
* Incrementalsearch and displayvalue set to shortcode
Rowsource = "select shortcode, description from mytable into cursor mycursor"
* Incrementalsearch and displayvalue set to description
* Rowsource = "select description,shortcode from mytable into cursor mycursor"
Columncount = 2
Boundcolumn = 1 && Or 2 - effects return value for controlsource
Controlsource = myTarget.Shortcode && Shortcode in column 1, boundcolumn 1
* Controlsource = myTarget.Description && Shortcode in column 1, boundcolumn 2
IncrementalSearch = .t.
As an end note having this code in lostfocus of combo might prevent headaches in some cases - especially if combo allowed adds, style = combobox - (though code looks silly) :
this.value = this.displayvalue
this.displayvalue = this.value
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