Microsoft KB Archive/138654

= How to Add Items to a Combo Box with RowSourceType of Value =

Article ID: 138654

Article Last Modified on 2/11/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q138654



SUMMARY
ComboBoxes with a RowSourceType of Value are used quite frequently for lists that have a defined number of choices. However, there are times when you may want to add what the user types into the combo box to the list. This can be done programmatically by using the RowSource Property.



Step-by-Step Example
 Open the Forms Designer, and place a combo box and text box on the form. With the combo box selected, click the Data tab in the Properties window. Set the RowSourceType property to Value (1), and set the RowSource Property to:

Choice1,Choice2

  Click the Methods tab, double-click the LostFocus event, and place the following code in the LostFocus event: IF NOT(This.DisplayValue$This.RowSource) This.RowSource = This.RowSource + "," + This.DisplayValue ENDIF  Run the form. In the combo box, type Choice3 and press ENTER. Choice3 should now be part of the list.

There are two important notes about this example. The first is that the item will only exist in the list as long as the form is running. Once you quit the form, the item will be removed from the list. The second is that there is a 255-characters limit to the length of the string that makes up the RowSource.

Additional query words: VFoxWin

Keywords: KB138654

-

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

© Microsoft Corporation. All rights reserved.