Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you really type in text as the data in a combo box?
Message
From
13/11/2002 11:58:40
 
 
To
13/11/2002 09:40:22
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00722103
Message ID:
00722187
Views:
20
Hi Pat.

I need a combo box that provides a value equal to either the item selected from the drop down list or the text typed into the text area. The FoxPro (6) documentation says "You can enter information in the text box portion or select an item form the list box portion" . I can enter text just fine in the text box portion, but the value of the combo box is never set to this text - it is set to null unless one of the list box items is selected. I have the style set to "0" (dropdown combo).

You must take some action to add the newly entered item to the combo's internal list.

Adding a new item to a ComboBox with style = 0-DropDown Combo is a pretty straightforward process because the control's Valid event fires whenever a selection is made from the list and again before it loses focus. When a user has typed something that is not in the current list, the control’s DisplayValue property will hold the newly entered data but the Value property will be empty. A little code in the Valid method of the control allows you to determine whether the user selected an item in the list or typed a value not in the list. For example the following code could be used:
IF  NOT( EMPTY( This.DisplayValue ) ) AND EMPTY( This.Value )
  *** The user has typed in a value not in the list
However, this will not be reliable if the RowSource allows for empty values so a better solution is to use either:
IF  NOT( EMPTY( This.DisplayValue ) ) AND This.ListIndex = 0

OR

If  NOT( EMPTY( This.DisplayValue ) ) AND This.ListItemID = 0 
You must then take action to add the new item to the control's RowSource. The code used to do this will be instance specific, depending on how the control is populated. If the combo's RowSourceType is "0-None" or "1-Value," use the AddItem or AddListItem method to add the new value to the list. If the RowSourceType is "2-Alias," "3-SQL Statement" or "6-Fields," the new item must be added to the underlying table and the combo or list box requeried to refresh its internal list. For RowSourceType "5-Array," add the item to the array and requery the control.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform