>>>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:
>>
>>
>>With this
>> .Rowsourcetype = 1
>> .Rowsource = ;
>> 'Description 1,pk123,Col31,'+;
>> 'Description 2,pk138,Col32,'+;
>> 'Description 3,pk178,Col33,'+;
>> 'Description 4,pk198,Col34'
>> .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