Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best approach for listbox on values
Message
De
12/07/2001 10:27:12
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
12/07/2001 10:13:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00529536
Message ID:
00529700
Vues:
30
>>>I am wondering what is the best approach to take when we have a listbox of type 1 - Value where we enter our own values in RowSourceType property. It's not like a listbox of type 3 - SQL where we can bound the control source to field on BoundColumn 2. Basically, what is the best approach to bound the control source when entering the values manually at the form designer level?
>>
>>Michel,
>>It's just the same with the exception recordpointer wouldn't move in a cursor where you could directly use myComboCursor.Anyfield to check selected item (single selection).
>>You just provide n values per row where n is columncount. ie:
>>
>>
*mycombo.init && All props left at their default
>>With this
>>  .Rowsourcetype = 1
>>  .Rowsource = ;
>>     'Description 1,pk123,Col31,'+;
>>     'Description 2,pk138,Col32,'+;
>>     'Description 3,pk178,Col33,'+;
>>     'Description 4,pk198,Col34'  && 3 per row
>>  .Columncount = 3
>>  .Boundcolumn = 2
>>  .Columnwidths = '100,50,50'
>>Endwith
>>
>>* A commandbutton click to check selected
>>With thisform.myCombo
>>  Messagebox( ;
>>    'Value : '+ .Value + chr(13)+;
>>    'Col1  : '+.List(.ListIndex,1)+chr(13)+;
>>    'Col2  : '+.List(.ListIndex,2)+chr(13)+;
>>    'Col3  : '+.List(.ListIndex,3) )
>>Endwith
Value returns column 2 (Boundcolumn) content but you can access any column value using List(ListIndex,ColNum) - (honestly I prefer List(Listindex,Col) approach vs value).
>>
>>Note: If you have a controlsource defined and it's numeric then better you set bound to .t. otherwise you get listindex.
>
>I prefer to just define it in the Init() of the form:
>
>
>* Setup of the cursor for listbox
>CREATE CURSOR TmpListbox (TypeRes C(11),TypeValue C(3))
>INSERT INTO TmpListbox (TypeRes,TypeValue) VALUES ('Description1','ShortDescription1')
>INSERT INTO TmpListbox (TypeRes,TypeValue) VALUES ('Description2','ShortDescription2')
>
>
>So, I could use the same approach as if it would come from a table in the listbox definition. Thus, all the code I need is just to put it in the Init() of the form.

A cursor :) Well then just go with Rowsourcetype=3 or fields, alias :

* Form.init
with this.myCombo
.RowsourceType = 3
.Rowsource = 'select * from mycursor into cursor crsMyCombo'
.Columncount = 2 && 1 to fcount() Whatever you prefer
.BoundColumn = 2
endwithCetin
Ç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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform