Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help! Multi-Column Dropdown Combo.
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00271898
Message ID:
00271905
Views:
26
>>Yes, that's correct, Evan. I've tried boundcolumn=2 and that made no difference at all.
>>
>>>I would imagine that you are doing something like displaying a code with a description. What you can do is set the boundcolumn to whichever column you want to store in the variable or table. You can then display 1 or both of the columns in the combo.
>>>
>>>>I've had no trouble with single column Combo boxes, but now I am trying to create a Dropdown Combo with two columns. The Rowsource is a SQL Select statement into a Cursor. I want the first two columns to display in the list and both be visible after selection.
>>>>
>>>>When the Combobox initialises, it is blank.
>>>>When the list drops down, both columns are showing fine.
>>>>On selection, only the first column shows in the display. If I can't display both columns, I need the second to display, not the first.
>>>>
>>>>How do I get both columns to be visible when the Combobox is first displayed and also after selection?
>>>>
>>>>I've tried lots of permutations - and searched the help. There must be something simple I'm missing. Can anyone help.
>>>>
>>>>I'm using VFP5a
>>>>
>>>>David O'Brien
>
>
>You might try to populate an array with your SQL Select Statement and build the values in the combo box from the array. Here is some code you might use: (this was used to build a combo box for Agent Numbers where the MstNo (Master Agent Number) displayed, but when dropped down, the Master Agent, Sub Agent and Name displayed.
>
>* AgntMst && Table from which values of combo box are derived.
>* Initialize cmbAgntMstID array
>lnArrayNoRows = 0
>LOCAL lcRS
>SELECT MstNo, SubNo, pID, MstName ;
> FROM AgntMst ;
> ORDER BY MstNo, SubNo ;
> INTO ARRAY this.s_aAgntMstID && Property on the form with combobox
>
>lnArrayNoRows = _TALLY
>LOCAL lcRS
>
>* Build cmbAgntMstID && combo box control
>WITH this.cmbAgntMstID
> .Clear && Remove All Items from combo
> IF lnArrayNoRows # 0
> * add Source Codes to combo
> FOR lnaCtr = 1 TO lnArrayNoRows
> lcRS = ALLTRIM(this.s_aAgntMstID(lnaCtr,1)) + ' / ' + ; ALLTRIM(this.s_aAgntMstID(lnaCtr,2))
> .AddListItem(lcRS,lnaCtr,1)
> .AddListItem(this.s_aAgntMstID(lnaCtr,4),lnaCtr,2)
> NEXT
> ENDIF && lnArrayRows # 0
>ENDWITH
>
>The boundcolumn is set to 1 and the columncount is set to 2. The init method sets the value in the combobox to the first element of the array. If you change the table from which the array is built, you merely create a method to rebuild the array and the combo box values.


FOLLOWUP:

If you want both columns to display in the combo box, change the SELECT statement for the array above to:

SELECT MstNo + ' - ' + SubNo AS MstNo, pID, MstName ;
FROM AgntMst ;
ORDER BY MstNo, SubNo ;
INTO ARRAY this.s_aAgntMstID && Property on the form with combobox

With the preceding statement, your boundcolumn 1 will be comprised of a value which is the value of the two columns you wanted together as one.

Bill
CySolutions, Medical Information Technology
You're only as good as your last
success, so . . .If it works. . .don't fix it!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform