Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie: Drop-down listbox with Fields RowsourceType
Message
De
08/05/2003 07:02:07
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/05/2003 16:00:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00785977
Message ID:
00786129
Vues:
18
>I have a drop-down listbox in Visual Class Form; code
>is shown below. See embedded comments for clarifications.
>
>QUESTION is below code snippets.
>
>I have code in my Visual Class Form init() routine:
>
>form.init()
>...
>...
>SELECT TRIM(DD_ships.sh_name)+" "+TRIM(DD_ships.sh_type)+"-"+TRIM(DD_ships.sh_hno) AS ship, ;
> DD_sdilist.sl_shipid,TRIM(DD_ships.sh_type),val(DD_ships.sh_hno), ;
> DD_sdilist.sl_idxtype ;
> FROM DD!DD_sdilist inner JOIN DD!DD_ships ON ;
> DD_sdilist.sl_shipid=DD_ships.sh_shipid ;
> &l_cWhere ;
> ORDER BY 3,4 INTO CURSOR curSDIlist
>...
>
>*// cboShip is drop-down listbox
>*// RowSourceType is 6 - Fields
>
>THISFORM.cboShip.ROWSOURCE="curSDIlist.ship,sl_shipid"
>...
>...
>
>
>* In cboShip.InteractiveChange() method code is:
>
>WITH THISFORM
>...
>...
>...
> SELECT DISTINCT dd_sdidata.si_index FROM dd_sdidata ;
> WHERE dd_sdidata.si_shipid=VAL(THIS.VALUE) INTO CURSOR
> curIndexList
>...
>...
>ENDWITH
>
>>>>>>>>>>>
>
>My question is how does the InteractiveChange() method for drop-down list pick the 2nd column (Field) from Rowsource for cboShip Value. I've confirmed this fact through debugging.
>
>FZ (Boston MA)

Donald,
Welcome. As Tracy pointed out BoundColumn = 2 provides that.
However when a combo/list has a rowsource of any kind that's an alias (fields,sql,query,alias) record pointer moves in its rowsource cursor/table as you walk within the items. And no matter how many columns of underlying cursor/table you use in conbo/list all columns are actually available to you.

ie:
with myCombo
 .RowSourceType = 6
 .RowSource = 'customer.Company,cust_id'
 .BoundColumn = 2
 .ColumnCount = 2
endwith
*Any time you could get cust_id with these methods :
? myCombo.Value
or :
with myCombo
 .List(.ListIndex,2) && 1 to get Company
endwith 

* But there is a more intuitive way (and prevents conversion if it's not character)
? customer.company, customer.cust_id, customer.contact
This is straight forward as record pointer in customer is moving as you navigate the combo/list. As you see you can get info from fields not included in combo/list too :) ie: With this approach your interactivechange call might be :
SELECT DISTINCT dd_sdidata.si_index FROM dd_sdidata ;
 WHERE dd_sdidata.si_shipid = curSDIlist.sl_shipid ;
 INTO CURSOR curIndexList
Showing you where that parameter value comes from right in place (and eliminates val() conversion).

Second as I can see you're first selecting into a cursor and then making that cursor RowSource. You could just make the SQL the rowsource itself with Rowsourcetype = 3. It not only prevents errors like 'curSDIlist not found' that might occur unless you workaround (seems you did) but lets you simply call combo.requery() if its parameters change (ie: select ...from ... where shippingID = thisform.txtShipID.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