Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best approach for listbox on values
Message
From
12/07/2001 10:13:18
 
 
To
12/07/2001 06:52:30
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00529536
Message ID:
00529687
Views:
25
>>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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform