Microsoft KB Archive/142281

= How to Display Columns Other than Default in a Combo Box =

Article ID: 142281

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q142281



SUMMARY
Combo boxes by default come up with an empty text area. However, you can display a value in the combo box other than the BoundColumn property value y using the DisplayValue Property in conjunction with the InteractiveChange Event. This article shows by example how to do it.



Step-by-Step Example
 Create a new form. Add the Customer table from the Samples\Data directory to the Data Environment of the form. This can be done by either right-clicking the form and selecting Data Environment from the menu or by selecting Data Environment from the View Menu. Drop a combo box on the form.  In the Properties Window, set the following properties: ColumnCount = 2 DisplayValue = "=Company" (without the quotes) RowSource = SELECT cust_id,company FROM CUSTOMER INTO CURSOR mycombo RowSourceType = 3 -SQL Statement NOTE: Code was tested with the RowSourceType set to 3 - SQL Select and 2 - Alias. However, you should be able to implement this logic with other RowSourceTypes. You can eliminate the display of the cust_id by setting the ColumnWidths Property to something like this: ColumnWidths = "0,100" (Eliminate the quotation marks if you are in the Property Window.)   Add the following code to the InteractiveChange event: This.DisplayValue = This.List(This.ListIndex,2)  Save and run the form.</ol>

The combo box should display the first company in the table. As you select different companies the name should remain in the combo box display.

Additional query words: VFoxWin

Keywords: KB142281

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.